1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 15:11:58 +00:00

fix(server): closed connections (#10013)

This commit is contained in:
Jason Rasmussen 2024-06-06 10:09:42 -04:00 committed by GitHub
parent ca12f3b15f
commit 4ad97ccded
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 13 deletions

View file

@ -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);
}),
),
);

View file

@ -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(),
});
}
}
}

View file

@ -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)) {