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
Fix(premature close) Redirect failing when response is chunked but empty #1222
Fix(premature close) Redirect failing when response is chunked but empty #1222
Conversation
186138a
to
86d3005
Compare
Going to take a look at this tomorrow. Just so I know, is #1064 and this PR just a fix to handle a older |
@jimmywarting #1064 is actually 2 fixes related to premature close problems. The first part is to handle the bad ending of chunked transfers, which is applicable to to all Node.js 10-14 (and I haven't tested 16). The second part is to fix the async iterator issue with Node.js 12. I will update #1064 to clarify. |
The reason why i asked was that it could be nice to remove the async iterator hack/fix if we decide to remove support for node < 14 sometime later, but i guess NodeJS will have added fetch into core at that point |
Yes, we can definitely remove the async iterator hack/fix next year when Node.js 12 goes EOL (https://github.com/nodejs/Release) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I downloaded your patch and tried both
fetch('https://blog.logrocket.com/feed')
.then(r => r.arrayBuffer())
.then(console.log)
// works in browser, Throws in node-fetch with Invalid response body while
// trying to fetch https://fex.baidu.com/feed.xml: Premature close
fetch('https://fex.baidu.com/feed.xml')
.then(r => r.arrayBuffer())
.then(console.log) // works in browser, and also this PR
…parate packets and where there is an additional data chunk in the same packet before the final chunk and EOM code.
925cb21
to
d19fdac
Compare
@jimmywarting Found the issues. Please give this fix a try. |
tested, works fine now on nodejs v16.5
Marking as draft then, mark as ready to review when you are done |
@tekwiz have you run some tests? |
Yes, apologies for the delay. The day job got in the way. It turns out the Node.js 16 does a better job of handling bad endings of chunked encodings -- it throws an Error with the simple message "aborted" instead of hanging or timing out. However, with the nonspecific-ness of that error and for the sake of consistency, my opinion is to leave the |
Tiered of waiting, When will this get checked in and build an |
Need at least 2 approvals for it to get merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
Yes at last now, will be greet to check #1237 |
Thinking we will skip a beta.11 with this pr (fix) and just publish v3.0.0 (stable) instead I thought this PR was needed cuz it broke something that used to work before. Gona take a closer look at #1237 now |
node-fetch PR that this work is based upon: node-fetch/node-fetch#1222
node-fetch PR that this work is based upon: node-fetch/node-fetch#1222 Co-authored-by: Jacob Ebey <jacob.ebey@live.com>
node-fetch PR that this work is based upon: node-fetch/node-fetch#1222 Co-authored-by: Jacob Ebey <jacob.ebey@live.com>
* Backport node-fetch redirect bugfix node-fetch PR that this work is based upon: node-fetch/node-fetch#1222 Co-authored-by: Jacob Ebey <jacob.ebey@live.com> * chore: fix changeset --------- Co-authored-by: Ben <benjamin.mchone@gmail.com> Co-authored-by: Jacob Ebey <jacob.ebey@live.com>
What is the purpose of this pull request?
What changes did you make? (provide an overview)
When an abort signal is given, the test for a properly closed chunked request should be skipped.
Which issue (if any) does this pull request address?
Is there anything you'd like reviewers to know?