You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an interesting issue with request that essentially never finishes.
It is tricky to reproduce, but everything boils down to proper timing such that there are response headers, but not response body yet.
Sometimes even though complete body was received (accumBytes is the same as Content-Length), body.on('end', ...) is never fired
I'm not sure how to fix the second one, one reason may be that response.size is 0 for some reason, looks like it is not read from headers or something. Hopefully maintainers can figure that out.
But at very least with mentioned PR merged it will handle timeouts on cloned response properly.
Reduced example of the code I'm dealing with is like this:
importfetchfrom"node-fetch";(async()=>{constresponse=awaitfetch('http://domain.tld/path',{timeout: 2000,},);console.log(response.status,response.headers);console.log(awaitresponse.clone().json());console.log('This may not be printed ever, without any errors');})();
I have an interesting issue with request that essentially never finishes.
It is tricky to reproduce, but everything boils down to proper timing such that there are response headers, but not response body yet.
In such circumstances I've uncovered 2 issues:
accumBytesis the same asContent-Length),body.on('end', ...)is never firedI'm not sure how to fix the second one, one reason may be that
response.sizeis0for some reason, looks like it is not read from headers or something. Hopefully maintainers can figure that out.But at very least with mentioned PR merged it will handle timeouts on cloned response properly.
Reduced example of the code I'm dealing with is like this: