Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split streams into more features #2491

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

MattiasBuelens
Copy link

@MattiasBuelens MattiasBuelens commented Dec 28, 2024

Prompted by the discussion in web-platform-tests/wpt#49829, I had a look at the current list of features in the streams group. Currently, there's only the "base" streams feature and a single async-iterable-streams extension for async iteration. However, there have been several additions over the years since we shipped BYOB support:

I suggest we add the following new features, and move them out of the base streams feature:

@github-actions github-actions bot added the feature definition Creating or defining new features or groups of features. label Dec 28, 2024
@MattiasBuelens
Copy link
Author

@jcscottiii FYI

Copy link
Contributor

@captainbrosset captainbrosset left a comment

Choose a reason for hiding this comment

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

Given the differences in browser support and ship dates, I agree that it makes sense to split Streams into multiple sub-features. These seem separate enough to me.

That said, I don't have enough experience with streams to know whether that's also how developers think of them.
The key aspect we use to define features on this repo is developer perception.
Some of the questions we try to answer to split things up might be:

  • Do web developers think of these features independently from each other?
  • Can they use streams already without these later additions?
  • Are these later additions improvements over the base feature?
  • Is there evidence of these additions being talked about on the web (StackOverflow, blogs, etc.)?

Let us know your thoughts. I'm not saying this isn't the right way to split, merely just leaving thought to provoke conversation.

Beyond that, I made a few tiny description proposals. Also, this should probably be merged again on the latest main branch and dist files should be re-generated.

features/readablestream-from.yml Outdated Show resolved Hide resolved
features/readablestreambyobreader-read-min.yml Outdated Show resolved Hide resolved
features/transferable-streams.yml Outdated Show resolved Hide resolved
features/transformstream-transformer-cancel.yml Outdated Show resolved Hide resolved
@MattiasBuelens
Copy link
Author

Can they use streams already without these later additions?

Yes, streams have been usable for quite a while, even before these recent additions.

Are these later additions improvements over the base feature?

Yes, these are all additive features. Generally, the objective has been to make streams easier to use, and better integrated with various parts of the Web Platform:

  • Transferable streams enables streams to be passed around between contexts (e.g. main thread and workers), similar to how ArrayBuffers are transferable. You could have done this yourself before (by manually postMessage()ing each chunk), but this makes it much easier to correctly handle backpressure, errors and cancellation.
  • ReadableStream.from() makes it easier to create a stream from other data sources, e.g. from an array. You could have done this yourself before (by manually constructing a stream and calling controller.enqueue()), but this makes it a one-liner in most cases.
  • Transformer.cancel() adds a way to respond to cancellation for a user-defined TransformStream. You could have done this before with a custom ReadableStream and WritableStream, but the new transformer method is much better at handling all possible edge cases.
  • ReadableStreamBYOBReader.read(view, {min}) extends the existing read(view) method. You could have done this before by manually calling read(view) in a loop until the view is sufficiently filled (like in this example), but the new min option makes this easier and enables potential optimizations in the future.

Do web developers think of these features independently from each other?
Is there evidence of these additions being talked about on the web (StackOverflow, blogs, etc.)?

Copy link
Contributor

@captainbrosset captainbrosset left a comment

Choose a reason for hiding this comment

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

This looks good to me. Thank you for providing the detailed rationale about these sub-features.

I don't think this needs to block this PR, but I do have one follow-up question: should the parent streams feature be Baseline Widely Available then?
Looking at that feature, it uses compute_from with the api.ReadableStreamBYOBReader BCD key, which makes it not available on Safari. But, reading the Streams guide you provided, it feels like the streams feature should be baseline if the base use cases have been available for a while already.

@MattiasBuelens
Copy link
Author

I don't think this needs to block this PR, but I do have one follow-up question: should the parent streams feature be Baseline Widely Available then?
Looking at that feature, it uses compute_from with the api.ReadableStreamBYOBReader BCD key, which makes it not available on Safari. But, reading the Streams guide you provided, it feels like the streams feature should be baseline if the base use cases have been available for a while already.

Personally, I would like to see BYOB become a separate feature. It's a bit weird how e.g. Compression Streams (which builds upon Streams) is Baseline Newly Available, while Streams is only Baseline Limited Available.

There was a discussion regarding BYOB as part of #2358. The decision there was to keep BYOB as part of the base feature, in order to match the status quo on https://caniuse.com/streams. We could consider splitting up the feature in both Baseline and caniuse, but I don't know what the impact of such a split would be on developers using this feature data today. 🤷‍♂️

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.

2 participants