From c54008b630d7249d54fa6248f87ee39625e80da4 Mon Sep 17 00:00:00 2001 From: wessberg Date: Thu, 20 May 2021 13:22:16 +0200 Subject: [PATCH] debug: temporarily allow stack traces in production --- src/api/middleware/error-middleware.ts | 9 ++------- src/api/server/server.ts | 2 +- test/api/api.test.ts | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/api/middleware/error-middleware.ts b/src/api/middleware/error-middleware.ts index d7b99fe..4e0304e 100644 --- a/src/api/middleware/error-middleware.ts +++ b/src/api/middleware/error-middleware.ts @@ -3,17 +3,12 @@ import {ApiError} from "../lib/api-error"; import {generateErrorHtml} from "../../util/html/generate-html"; import {pickAccept} from "../util/util"; -interface ErrorMiddlewareOptions { - removeStackTrace: boolean; -} +interface ErrorMiddlewareOptions {} export const errorMiddleware = - (options: Partial = {}) => + (_options: Partial = {}) => async (ex: Error | ApiError, req: Request, res: Response, _: NextFunction): Promise => { const apiError = ApiError.ensureApiError(ex); - if (options.removeStackTrace) { - apiError.stack = undefined; - } const contentType = pickAccept(req.header("accept")); diff --git a/src/api/server/server.ts b/src/api/server/server.ts index fc6a5b5..d36ddae 100644 --- a/src/api/server/server.ts +++ b/src/api/server/server.ts @@ -45,7 +45,7 @@ export class Server implements IServer { await this.metricsService.configureErrorHandlers(app); // Apply fall-through error middleware - app.use(errorMiddleware({removeStackTrace: this.config.production})); + app.use(errorMiddleware()); this.app = app; } diff --git a/test/api/api.test.ts b/test/api/api.test.ts index b834aaf..f09d826 100644 --- a/test/api/api.test.ts +++ b/test/api/api.test.ts @@ -59,7 +59,7 @@ test(`Generates an JSON-formatted welcome payload when a request is sent to '${c } }); -test.only(`Sends metrics data when an unsupported User-Agent header is discovered, but still responds with OK`, async t => { +test(`Sends metrics data when an unsupported User-Agent header is discovered, but still responds with OK`, async t => { const metricsService = container.get(); const result = await sendRequest({ path: `${constant.endpoint.polyfill}?features=intersection-observer`,