Fail safe on loggingHTTP requests
MODIFY
src/utils/Logging.ts
src/utils/Logging.ts
@@ -163,6 +163,7 @@ export default class Logging {
}
public static logExpressRequest(req: Request, res: Response, next: NextFunction): void {
+ try {
const userToken = Logging.getUserTokenFromHttpRequest(req);
let tenantID: string;
if (userToken) {
@@ -189,11 +190,14 @@ export default class Logging {
headers: req.headers,
}
});
+ } finally {
next();
}
+ }
public static logExpressResponse(req: Request, res: Response, next: NextFunction): void {
res.on('finish', () => {
+ try {
// Retrieve Tenant ID if available
let tenantID: string;
if (req.user) {
@@ -222,7 +226,9 @@ export default class Logging {
headers: res.getHeaders(),
}
});
+ } finally {
next();
+ }
});
}

Fail safe on loggingHTTP requests