From 363e6a63bea6620dda07933799ab23ac7dc6bd8c Mon Sep 17 00:00:00 2001 From: Jon Ball Date: Fri, 4 Aug 2023 13:22:08 -0400 Subject: [PATCH] fix(express-wrapper): dont override status code in req In the event of an error in handleRequest, only set the status code on the request if it hasn't already been set. Overriding the status code in the event of an error results in incorrect reporting of the error status code using plugins such as prom-bundle to generate metrics. --- packages/express-wrapper/src/request.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/express-wrapper/src/request.ts b/packages/express-wrapper/src/request.ts index dd57e310..dfeae64b 100644 --- a/packages/express-wrapper/src/request.ts +++ b/packages/express-wrapper/src/request.ts @@ -131,7 +131,10 @@ export const handleRequest = ( const response = await serviceFn(handlerParams); responseEncoder(httpRoute, response)(req, res, next); } catch (err) { - res.status(500).end(); + if (!res.statusCode) { + res.status(500); + } + res.end(); next(); return; }