-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
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:
- Timeouts are not propagated to cloned responses, so those never time out (fixed by Propagate size and timeout to cloned response #664)
- Sometimes even though complete body was received (
accumBytesis the same asContent-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:
import fetch from "node-fetch";
(async () => {
const response = await fetch(
'http://domain.tld/path',
{
timeout: 2000,
},
);
console.log(response.status, response.headers);
console.log(await response.clone().json());
console.log('This may not be printed ever, without any errors');
})();Reactions are currently unavailable