From 84699031893260927d409b4f7ddf221d47fd9d28 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sat, 26 Feb 2022 17:33:27 +0100 Subject: [PATCH] Fixing ServerTimingMW #437 --- src/backend/middlewares/ServerTimingMWs.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/middlewares/ServerTimingMWs.ts b/src/backend/middlewares/ServerTimingMWs.ts index ec0f9bd5..e40ae26b 100644 --- a/src/backend/middlewares/ServerTimingMWs.ts +++ b/src/backend/middlewares/ServerTimingMWs.ts @@ -42,6 +42,8 @@ export const ServerTime = (id: string, name: string) => { }; +const forcedDebug = process.env.NODE_ENV === 'debug'; + export class ServerTimingMWs { @@ -49,8 +51,8 @@ export class ServerTimingMWs { * Add server timing */ public static async addServerTiming(req: Request, res: Response, next: NextFunction): Promise { - if (Config.Server.Log.logServerTiming === false || !req.timing) { - next(); + if ((Config.Server.Log.logServerTiming === false && !forcedDebug) || !req.timing) { + return next(); } const l = Object.entries(req.timing).filter(e => e[1].endTime).map(e => `${e[0]};dur=${e[1].endTime};desc="${e[1].name}"`); res.header('Server-Timing', l.join(', '));