From 1217bc1dacddb821d69faafd71eb057a3b484b6c Mon Sep 17 00:00:00 2001 From: Jay McDoniel Date: Mon, 16 Jan 2023 12:21:38 -0800 Subject: [PATCH] fix(fastify): return the response on exception Fastify requires us to return the response object when handling async methods and dealing with exceptions, otherwise a thenable gets wrapped and improperly handled later causing an exception. This is shown by [this repo][1] and discuessed in [this issue][2]. [1]: https://github.com/sgrigorev/nestjs-compress-issue [2]: https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312 --- packages/core/router/router-proxy.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/core/router/router-proxy.ts b/packages/core/router/router-proxy.ts index c1384e54504..30087b0c154 100644 --- a/packages/core/router/router-proxy.ts +++ b/packages/core/router/router-proxy.ts @@ -22,6 +22,7 @@ export class RouterProxy { } catch (e) { const host = new ExecutionContextHost([req, res, next]); exceptionsHandler.next(e, host); + return res; } }; } @@ -46,6 +47,7 @@ export class RouterProxy { } catch (e) { const host = new ExecutionContextHost([req, res, next]); exceptionsHandler.next(e, host); + return res; } }; }