Skip to content

Commit

Permalink
fix(fastify): return the response on exception
Browse files Browse the repository at this point in the history
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]: fastify/fastify-compress#215 (comment)
  • Loading branch information
jmcdo29 committed Jan 16, 2023
1 parent 0e0e24b commit 1217bc1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/core/router/router-proxy.ts
Expand Up @@ -22,6 +22,7 @@ export class RouterProxy {
} catch (e) {
const host = new ExecutionContextHost([req, res, next]);
exceptionsHandler.next(e, host);
return res;
}
};
}
Expand All @@ -46,6 +47,7 @@ export class RouterProxy {
} catch (e) {
const host = new ExecutionContextHost([req, res, next]);
exceptionsHandler.next(e, host);
return res;
}
};
}
Expand Down

0 comments on commit 1217bc1

Please sign in to comment.