Skip to content

Disambiguate fetch-request-streams feature#3361

Open
jgraham wants to merge 1 commit intomainfrom
fetch_streams
Open

Disambiguate fetch-request-streams feature#3361
jgraham wants to merge 1 commit intomainfrom
fetch_streams

Conversation

@jgraham
Copy link
Copy Markdown
Collaborator

@jgraham jgraham commented Sep 17, 2025

Rewrite the fetch-request-streams feature to make it more clear what precise property it covers, and add a new fetch-body-stream feature to cover the body option to the fetch function supporting ReadableStream objects.

@jgraham jgraham requested a review from ddbeck September 17, 2025 11:31
@github-actions github-actions bot added the feature definition Creating or defining new features or groups of features. label Sep 17, 2025
@jgraham
Copy link
Copy Markdown
Collaborator Author

jgraham commented Sep 22, 2025

Based on web-platform-tests/interop#1072 (comment) another option here is to just move api.Request.Request.request_body_readablestream into Fetch upload streams, although it won't accurately reflect the fact that some Request.body usecases already work in Safari (but not Firefox).

Rewrite the fetch-request-streams feature to make it more clear what
precise property it covers, and add a new fetch-body-stream feature to
cover the `body` option to the `fetch` function supporting
`ReadableStream` objects.
@jgraham
Copy link
Copy Markdown
Collaborator Author

jgraham commented Sep 30, 2025

OK, I've updated this to just make the more minimal change of requiring that the Request body property feature just requires both that you get a body property on Request and also that you can specify it in the constructor.

I'm not delighted with that, because it obscures the fact that part of the feature is already available in Safari, but it's better than the status quo.

@@ -1,5 +1,6 @@
name: Fetch upload streams
description: A `fetch()` request uploads a stream of data to the server when a request's `body` property is a `ReadableStream` object.
name: Request body property
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing I'm not 100% sure about is the name. Isn't it a problem that we're loosing the "stream" part of it?
According to MDN, the body part of a request can either be null or a stream.
So, really, it's only used for streaming requests to a server, right?

What other things can it be used for?

name: Fetch upload streams
description: A `fetch()` request uploads a stream of data to the server when a request's `body` property is a `ReadableStream` object.
name: Request body property
description: A `ReadableStream` can be used as the body of a `Request` object.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: A `ReadableStream` can be used as the body of a `Request` object.
description: `Request` objects have a `body` property and it can be used as a `ReadableStream`.

@ddbeck
Copy link
Copy Markdown
Collaborator

ddbeck commented Apr 9, 2026

This came up on today's WebDX call. I have now dug into this and I think I figured out my source of confusion around this feature (it's mostly because the BCD is very messy and disorganized). Here's the story, I think:

  • If I understand correctly, there has always been body field in the RequestInit dictionary for fetch() and Request(). From fetch's inception (probably?), you could use the same body types as XHR's send().
  • Later, ReadableStream support was added to RequestInit's body.
  • Another point of confusion here: Request.prototype.body was also added (see also: tests), but it's a ReadableStream — even if the body was something else.

This suggests to me that BCD could use some fixes here. It ought to have these keys (bolded for this feature):

  • api.fetch.init_body_parameter, supported since api.fetch has been supported and assigned to the main fetch feature
  • api.fetch.init_body_parameter.readablestream, probably moved from api.fetch.body_readablestream and assigned to the feature in this PR
  • api.Request.Request.init_body_parameter, supported since api.Request.Request has been supported and assigned to the main fetch feature
  • api.Request.Request.init_body_parameter.readablestream, probably moved from api.Request.Request.request_body_readablestream and assigned to the feature in this PR

This also makes me think that the original name is basically right, but the description could be reworked to emphasize the change in body, something like this:

The fetch() method and Request() constructor accept a ReadableStream object as the request body, to stream upload data to the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature definition Creating or defining new features or groups of features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants