Re: [whatwg/fetch] Streaming upload (Issue #1438)

Sure. I wasn't very clear. I meant: "we are blocking full duplex support that doesn't require a flag on the request to enable". In my eyes it would be very unfortunate if full duplex always required a flag to opt in, especially considering how well HTTP/2 and HTTP/3 support full duplex. This statement is made on the assumption that if upload streaming were to ship in implementations with only simplex support, some users may start making requests to servers that process requests as full duplex, and then if/once those implementations do support full duplex streams the user facing behavior on the client would change and break existing code.

Let me start by elaborating the problem of duplex and simplex in the same API:

A little diagram of a full duplex request:

```
            : Time                :`
Conn init   : ...                 :
Header send :    ..               :
Req stream  :      .............  :
Header recv :              ..     :
Resp stream :                .... :
```

If a client does not support full duplex streaming, this would be exposed in the Fetch API as follows:

```
                     : Time 
Req stream done      :                  x  :
`fetch` promise done :                  x  :
Resp stream done     :                   x :
```

If a client does support full duplex streaming, it would be exposed as so:

```
                     : Time 
Req stream done      :                  x  :
`fetch` promise done :               x     :
Resp stream done     :                   x :
```

This means that with full duplex streaming, request errors can not be returned via the Promise returned from `fetch`, because in some cases the promise will already be resolved by the time an error occurs in the request stream.

After thinking about this some more, I think that the same API supporting both duplex and simplex streaming without a toggle is going to be rather problematic, and not ever backwards compatible (see #1254 for more on that).

Maybe a `streaming: "simplex" | "duplex"` option would work? If we set the default to "duplex" and have implementations which are simplex only error on that mode, we can allow the default to be duplex and still allow. That means that to use upload streaming in a simplex implementation, one would always need to specify `streaming: "simplex"`.

This essentially inverts the `fullDuplex` option that you had proposed elsewhere.

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

Message ID: <whatwg/fetch/issues/1438/1158828785@github.com>

Received on Friday, 17 June 2022 12:36:36 UTC