mirror of
https://github.com/immich-app/immich.git
synced 2024-11-24 08:52:28 +02:00
fix(server): closed connections (#10013)
This commit is contained in:
parent
ca12f3b15f
commit
4ad97ccded
@ -9,7 +9,7 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { Observable, catchError, throwError } from 'rxjs';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { isConnectionAborted, routeToErrorMessage } from 'src/utils/misc';
|
||||
import { routeToErrorMessage } from 'src/utils/misc';
|
||||
|
||||
@Injectable()
|
||||
export class ErrorInterceptor implements NestInterceptor {
|
||||
@ -21,15 +21,13 @@ export class ErrorInterceptor implements NestInterceptor {
|
||||
return next.handle().pipe(
|
||||
catchError((error) =>
|
||||
throwError(() => {
|
||||
if (error instanceof HttpException === false) {
|
||||
const errorMessage = routeToErrorMessage(context.getHandler().name);
|
||||
if (!isConnectionAborted(error)) {
|
||||
this.logger.error(errorMessage, error, error?.errors, error?.stack);
|
||||
}
|
||||
return new InternalServerErrorException(errorMessage);
|
||||
} else {
|
||||
if (error instanceof HttpException) {
|
||||
return error;
|
||||
}
|
||||
|
||||
const errorMessage = routeToErrorMessage(context.getHandler().name);
|
||||
this.logger.error(errorMessage, error, error?.errors, error?.stack);
|
||||
return new InternalServerErrorException(errorMessage);
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
@ -29,9 +29,11 @@ export class HttpExceptionFilter implements ExceptionFilter {
|
||||
};
|
||||
}
|
||||
|
||||
response.status(status).json({
|
||||
...responseBody,
|
||||
correlationId: this.cls.getId(),
|
||||
});
|
||||
if (!response.headersSent) {
|
||||
response.status(status).json({
|
||||
...responseBody,
|
||||
correlationId: this.cls.getId(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ export const sendFile = async (
|
||||
|
||||
await access(file.path, constants.R_OK);
|
||||
|
||||
return _sendFile(file.path, options);
|
||||
return await _sendFile(file.path, options);
|
||||
} catch (error: Error | any) {
|
||||
// ignore client-closed connection
|
||||
if (isConnectionAborted(error)) {
|
||||
|
Loading…
Reference in New Issue
Block a user