Nest: Using @Res() the response freezes

Created on 20 Sep 2020  路  7Comments  路  Source: nestjs/nest

Bug Report

Current behavior

When the controller method has @Res as a parameter, the response freezes

Input Code

...
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
  }

Without @Res()


image

With @Res()

image

Environment


Nest version: 7.5.1

For Tooling issues:

  • Node version: v14.11.0
  • Platform: Windows
  • Using TypeORM
needs triage

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.

All 7 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mishelashala picture mishelashala  路  3Comments

rlesniak picture rlesniak  路  3Comments

anyx picture anyx  路  3Comments

artaommahe picture artaommahe  路  3Comments

janckerchen picture janckerchen  路  3Comments