-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Posting to Endpoint with Express using Content-Type: application/json does not emit events to req.on('close') #10389
Comments
I added an express version to the repo, so you can run them from same repo to see that express behaves as you would expect, and nestjs is not. |
btw you forgot to call I just tested your repro with v8 and v9. None of them emits the 'close' nor the 'end' event on that |
after investigating that a bit, I found this weird(?) behavior: nest/packages/core/router/router-execution-context.ts Lines 139 to 151 in 8e3af06
adding right before L149, it will make that |
I just tested something: if we remove the Here's an up-to-date reproduction: https://gitlab.com/micalevisk/nestjs-issue-10389 |
@elucidsoft Were you able to find a workaround for this issue? |
another thing that I observed: nest/packages/core/router/router-execution-context.ts Lines 141 to 151 in 15cb568
if we drop the |
Is there an existing issue for this?
Current behavior
The req.on('close') event is not emitting when the content-type: applicaiton/json header is set. This makes no sense, the content-type header should not change the behavior when the connection is closed. This use to work, the behavior has somehow changed in either upgrade 7 or 8. We just observed this behavior, but we have done several nestjs upgrades and we are not sure when the behavior started. This took an extremely long time to track down, and is rather critical to our workflow, can please advise a temp workaround for us would be very helpful!!
Minimum reproduction code
https://github.com/elucidsoft/nestjs-broken-middleware
Steps to reproduce
Working without Header
content-type:
header NOT set.Broken with application/json Content-Type header
content-type: application/json
header set.Expected behavior
Event should emit no matter the content-type set.
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
9.1.4
Packages versions
I also verified this is broken in 8.x
Node.js version
16.14.2
In which operating systems have you tested?
Other
I verified this behavior on multiple platforms of Linux, inside docker, and outside docker, with multiple REST clients. All observed same behavior.
The text was updated successfully, but these errors were encountered: