express-slow-down: On v1.4.1 when slow delay is triggered the http request end up hanging up indefinitly and never being resolved
On v1.4.1 when slow delay is triggered the http request end up hanging up indefinitly and never being resolved
I’m on Windows with NodeJS v16.15.0
From what i saw the issue is that on this line we are sending the req object and with this object being sent the on-finished library trigger immediatly the onFinished event because the req.complete is already set (complete on req mean that the parsing of the request is done but not the http context being resolved source )
There are 2 possible solutions :
- Using the
resobject instead of thereqone on the line linked above - Not using
on-finishedlibrary at all and replacing line linked above withreq.on('close', () => {
I personnaly prefer the second solution because it means One less dependency to have so much cleaner to me …
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (12 by maintainers)
working perfectly !! Nice work !!
@ntedgi @nfriedly @danursin I finally was able to reproduce the bug :
Apparently its the body-parser causing the “issue” because it reads the request body and this was triggering the request on-finished event, which is perfectly normal (thats the whole point of request on-finished).
Steps to reproduce
npm i express express-slow-down body-parserHow to fix :
Refer to my 2 solutions on the first post of this issue for possible fix solutions.
Maybe “real world” isn’t the best description; I was thinking of something that still runs inside of jest (so it would run on node 14,16, and 18 on windows, mac, and linux in CI) - but it would use an actual HTTP server and actual HTTP requests, both in node.js - possibly in the same process, possibly in separate processes.