-
Notifications
You must be signed in to change notification settings - Fork 30k
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
stream.pipeline(httpResponse, decompressStream)
emits error three times
#31029
Comments
See 6480882. |
cc: @mcollina |
Let's revert 6480882 and try again - I'm swamped, it would be great if somebody else took care of it. |
There's no need to revert that. I would just replace: node/lib/internal/streams/pipeline.js Lines 46 to 54 in 6480882
with if (isRequest(stream.req)) return stream.req.abort();
if (typeof stream.destroy === 'function') return stream.destroy(err); The same is already done if you provide node/lib/internal/streams/pipeline.js Line 45 in 6480882
|
Ping @ronag |
Yes, For now I think @szmarczak suggestion makes sense. @szmarczak would you like to create a PR? I'll investigate later whether that would have any impact on what 6480882 was trying to fix. |
Sure, will do today. |
destroy(err) on http response will propagate the error to the request causing 'error' to be unexpectedly emitted. Furthermore, response.destroy() unlike request.abort() does not _dump buffered data. Fixes a breaking change introduced in nodejs@6480882. Prefer res.req.abort() over res.destroy() until this situation is clarified. Fixes: nodejs#31029 Refs: nodejs@6480882
destroy(err) on http response will propagate the error to the request causing 'error' to be unexpectedly emitted. Furthermore, response.destroy() unlike request.abort() does not _dump buffered data. Fixes a breaking change introduced in 6480882. Prefer res.req.abort() over res.destroy() until this situation is clarified. Fixes: #31029 Refs: 6480882 PR-URL: #31054 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
destroy(err) on http response will propagate the error to the request causing 'error' to be unexpectedly emitted. Furthermore, response.destroy() unlike request.abort() does not _dump buffered data. Fixes a breaking change introduced in nodejs@6480882. Prefer res.req.abort() over res.destroy() until this situation is clarified. Fixes: nodejs#31029 Refs: nodejs@6480882 PR-URL: nodejs#31054 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
destroy(err) on http response will propagate the error to the request causing 'error' to be unexpectedly emitted. Furthermore, response.destroy() unlike request.abort() does not _dump buffered data. Fixes a breaking change introduced in 6480882. Prefer res.req.abort() over res.destroy() until this situation is clarified. Fixes: #31029 Refs: 6480882 PR-URL: #31054 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Linux solus 5.4.1-137.current #1 SMP PREEMPT Sat Dec 7 15:17:22 UTC 2019 x86_64 GNU/Linux
If you run the example above, the error will be emitted three times:
stream error
(oh no
)pipeline error
(oh no
)request error
(oh no
)I did not expect the
ClientRequest
instance to throw.It's because
response.destroy(error)
callssocket.destroy(error)
directly.ClientRequest
catches the error and throws it again.But why does it call
response.destroy(error)
?Well, it happens because of 6480882 (previously it just called
response.destroy()
).If you run the example in Node.js 12, you will get these results:
stream error
(Cannot call write after a stream was destroyed
)pipeline error
(Cannot call write after a stream was destroyed
)stream error
(oh no
)I just want to say that the new behavior is correct, but
ClientRequest
should not throw if usingpipeline
withresponse
.The text was updated successfully, but these errors were encountered: