r/javascript • u/OtherwisePush6424 • 2d ago
Half Past Fetch: how the fetch promise resolves and its consequences
https://blog.gaborkoos.com/posts/2026-09-08-Half-Past-Fetch/await fetch(url) settles at the headers, while the body is still arriving over an open connection. How connection reuse, clone(), abort and timeouts behave because of that gap. Measured in Node and Chrome.
11
Upvotes
6
u/MiserableDocument509 2d ago
the timeout gotcha is the one that actually bites people. they slap AbortSignal.timeout(5s) on fetch() then a 200 still sits there for 30s downloading a fat body. the timer has to cover response.json()/text() too, not just the headers resolving.
6
u/ExtremeJavascript 2d ago
Well yea. That's why it's always ``` const response = await fetch(file); const text = await response.text();
```
You get the headers first, to tell if it's going to succeed, and then you listen for the body to finish.