When the controller method has @Res as a parameter, the response freezes
...
import {Response} from 'express'
import {Res} from '@nestjs/common'
...
@Get(':id')
findOne(@Param('id') id: string, @Res() res: Response) {
const user = this.usersService.findById(id)
return user
}
Nest version: 7.5.1
For Tooling issues:
- Node version: v14.11.0
- Platform: Windows
- Using TypeORM
This is expected and documented
But the response never comes in
As soon as you add @Res()
to the handler, you must handle the response yourself. This is the excepted and documented functionality. Please use our Discord for further support
I had handle It too. I removed the handler to simplify.
If you really do handle it and it freezes, please provide a minimum reproduction
My friend, I will explain again. The scenario is that just by using @Res as a parameter it freezes when serializing the object in the response. If I return @ Res.send () it works, but when serializing it freezes. If you don't want to help me, don't be unpleasant either, we are on the same side of the opensource initiative, trying to help improve what we can.
Yes, in the documentation it's mentioned that if you use @Res()
for any reason in that route handler (class method) you must handle the response yourself. If you do not handle it, the request hangs. This is the expected functionality. I would love to help you if you are noticing something other than that, but so far it doesn't sound like that is the case.
And apologies if I come off as rude, but we have a discord server dedicated to support and many times we get people submitting issues without fully reading the documentation.
If you're still having a problem, please provide a minimum reproduction repository and we'll take a look as soon as possible.
Most helpful comment
Yes, in the documentation it's mentioned that if you use
@Res()
for any reason in that route handler (class method) you must handle the response yourself. If you do not handle it, the request hangs. This is the expected functionality. I would love to help you if you are noticing something other than that, but so far it doesn't sound like that is the case.And apologies if I come off as rude, but we have a discord server dedicated to support and many times we get people submitting issues without fully reading the documentation.
If you're still having a problem, please provide a minimum reproduction repository and we'll take a look as soon as possible.