Re: [whatwg/fetch] Fetch body streams are not full duplex (#1254)

AjaniBilby left a comment (whatwg/fetch#1254)

@Hashbrown777 two tandum requests sounds easy until you start counting the edge cases:

1. **Request failure**: If one or other request closes for some reason, do cancel the other? Attempt a restart?
2. **Fine load balancer control**: You need to make sure both requests end up on the same server, or have to use some state management like a DB to communicate across machines.
3. **Context Alignment**: You need to make sure not only both requests are executing on the same device/VM, but also they are in the same context. In some langauges and frameworks if the two requests end up on a different thread of execution this will add extreme amounts of overhead.

The only current work around would be to put the request through a binary websocket.

Also it's really not that bespoke. You only need about [~200 lines](https://github.com/AjaniBilby/recommend-moe/blob/main/app/util/form.ts#L8-L188) to write a streamed `multipart/form-data` iterator. Then another [200 lines](https://github.com/AjaniBilby/recommend-moe/blob/main/app/util/format/csv.ts#L43) to write a csv iterator that can ingest the form value chunk stream. Of course the examples I gave are JS, but even if you `10x` them into a real langauge, 2000 lines isn't much.

I'm honestly just surprised browsers aren't already capable of this, since they can render incomplete html as it's being streamed down the wire. I would have thought that would be a harder feature. But I guess that shows I don't know what network optimsations are going on under the hood.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/1254#issuecomment-3060596768
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/1254/3060596768@github.com>

Received on Friday, 11 July 2025 05:25:08 UTC