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
Destroying the response body stream does not abort the request in node-fetch v2 #1762
Comments
|
@emcsween Have you figured out how to resolve this issue? I got the same bug. |
@chungquantin I use the workaround described above in the description of this issue. |
In node-fetch v3, if the response body stream is destroyed before the request completes, the request is aborted. This is useful when piping the body into another stream using
pipeline()
:If an error occurs,
pipeline()
destroysresponse.body
, which in turn aborts the request.Unfortunately, this doesn't work in node-fetch v2.
Reproduction
This script requests a large file and immediately destroys the response body stream:
With node-fetch v2, a socket stays open. (I verify this with
ss -tnp | grep pid=PID
)With node-fetch v3, this doesn't happen.
Your Environment
Additional context
As a workaround, one can use an AbortController to abort the request when the response body is closed. Something like:
But it would be nicer if node-fetch did that automatically instead.
The text was updated successfully, but these errors were encountered: