1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-01 08:31:59 +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'; } from '@nestjs/common';
import { Observable, catchError, throwError } from 'rxjs'; import { Observable, catchError, throwError } from 'rxjs';
import { ILoggerRepository } from 'src/interfaces/logger.interface'; import { ILoggerRepository } from 'src/interfaces/logger.interface';
import { isConnectionAborted, routeToErrorMessage } from 'src/utils/misc'; import { routeToErrorMessage } from 'src/utils/misc';
@Injectable() @Injectable()
export class ErrorInterceptor implements NestInterceptor { export class ErrorInterceptor implements NestInterceptor {
@ -21,15 +21,13 @@ export class ErrorInterceptor implements NestInterceptor {
return next.handle().pipe( return next.handle().pipe(
catchError((error) => catchError((error) =>
throwError(() => { throwError(() => {
if (error instanceof HttpException === false) { if (error instanceof HttpException) {
const errorMessage = routeToErrorMessage(context.getHandler().name);
if (!isConnectionAborted(error)) {
this.logger.error(errorMessage, error, error?.errors, error?.stack);
}
return new InternalServerErrorException(errorMessage);
} else {
return error; 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({ if (!response.headersSent) {
...responseBody, response.status(status).json({
correlationId: this.cls.getId(), ...responseBody,
}); correlationId: this.cls.getId(),
});
}
} }
} }

View file

@ -65,7 +65,7 @@ export const sendFile = async (
await access(file.path, constants.R_OK); await access(file.path, constants.R_OK);
return _sendFile(file.path, options); return await _sendFile(file.path, options);
} catch (error: Error | any) { } catch (error: Error | any) {
// ignore client-closed connection // ignore client-closed connection
if (isConnectionAborted(error)) { if (isConnectionAborted(error)) {