New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NestJS 9 with Fastify ignores @Res() in controller #10333
Comments
This actually might be related to something I'm looking into with |
Did you have a chance to find the root cause @jmcdo29? Let me know and I can take over if you're busy 🙌 |
@kamilmysliwiec that might be best. What SirReiva added might be relevant here too |
@SirReiva's answer explains and solves the issue I was running into. Thanks, everyone. |
Let's track this here #10459 |
Did you read the migration guide?
Is there an existing issue that is already proposing this?
Potential Commit/PR that introduced the regression
No response
NestJS version
8.4.7 -> 9.1.2
Describe the regression
NestJS appears to be ignoring the use of @res() to override Nest's standard code for responding to a request, specifically when using Fastify.
In version 8, Nest doesn't attempt to respond to requests at all if it sees @res() in the controller's parameters and allows you to respond when needed (for example, any asynchronous code not through a Promise). In version 9, the same code will respond immediately, ignoring your res.send if it doesn't happen synchronously.
Note: NestJS 9 using Express behaves the same way as NestJS 8 using Fastify.
Minimum reproduction code
https://github.com/coryroloff/nestjs-res-bug
Input code
No response
Expected behavior
To test NestJS 8, run the following:
You will get the response "hello world" back. This is expected behavior.
To test NestJS 9 with Fastify, run the following:
You will get an empty response body back, instead of the expected "hello world".
To test NestJS 9 with Express, run the following:
You will get the response "hello world" back. This is expected behavior.
Other
No response
The text was updated successfully, but these errors were encountered: