clone() hangs with large response in Node
See original GitHub issueI hit this bug today, it was caused by https://github.com/bitinn/node-fetch/issues/386
The bug makes ky-universal
not useable at all in node. (You don’t know when the code will hang as you don’t know the response size ahead of time)
Is there a way to remove clone()
from the source code?
IssueHunt Summary
xxczaki has been rewarded.
Backers (Total: $80.00)
issuehunt ($80.00)
Submitted pull Requests
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:8 (2 by maintainers)
Top Results From Across the Web
node.js http.get hangs after 5 requests to remote site
In your code, you don't consume the actual response sent by Google. So the agent assumes that you're not done with the request,...
Read more >Top 10 Most Common Node.js Developer Mistakes - Toptal
Invoking this “sortUsersByAge” function may be fine if run on a small “users” array, but with a large array, it will have a...
Read more >Troubleshooting queries - Amazon Redshift
Your client connection to the database appears to hang or time out when running long queries, such as a COPY command. In this...
Read more >15 Common Error Codes in Node.js and How to Fix Them
ECONNRESET. ECONNRESET is a common exception that occurs when the TCP connection to another server is closed abruptly, usually before a response ......
Read more >This is why your Node.js application is slow
/* Sample promises to simulate asynchronous operation. * Let's assume these are sample DB operations and their equivalent response time. *. */.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@gutenye @sindresorhus In version
3.0.0
ofnode-fetch
you will be able to manually sethighWaterMark
and prevent this issue from happening 😄See this PR
It would be pretty challenging to re-implement
.clone()
ourselves. In doing so, we would probably end up creating more new bugs than we solved. The only practical way forward that I see here would be to just not clone the response at all.We currently clone in three places:
afterResponse
hooksky().json()
)I’m not sure which, if any, of these places would be safe to remove. None of them seem particularly important to me, though I like having them for safety.
It’s worth noting that we only call
.clone()
if you use one of the above mentioned features. So you can actually avoid this problem if you can live without those features.For example, if
.clone()
is being called because you are using the.json()
method like this:It’s perfectly fine to re-write that to:
… in which case
.clone()
is not called. The only caveat, beyond it being more verbose, is that you will also have to set theAccept: application/json
header yourself, if you need that.Other than those workarounds, I’m not sure there’s much we can do, since we are using the API correctly and this is really an upstream issue. We could explore alternative fetch polyfills, but I suspect that would again introduce its own set of problems. Let’s keep an eye on that issue you referenced.
In the meantime, should we consider removing
.clone()
internally and, if so, where? Removing3
seems the safest to me and it’s probably the most common case as well.