Skip to content

Use async_sequence in ReadableStream.from#1372

Open
MattiasBuelens wants to merge 12 commits intowhatwg:mainfrom
MattiasBuelens:rs-from-async-sequence
Open

Use async_sequence in ReadableStream.from#1372
MattiasBuelens wants to merge 12 commits intowhatwg:mainfrom
MattiasBuelens:rs-from-async-sequence

Conversation

@MattiasBuelens
Copy link
Copy Markdown
Collaborator

@MattiasBuelens MattiasBuelens commented May 1, 2026

Replace our manual async iterator logic with the new Web IDL async_sequence<T> type and its associated operations (added in whatwg/webidl#1397).

This comes with one behavioral change: ReadableStream.from("abc") used to iterate over the Unicode code points of the string (per String.prototype[Symbol.iterator]), but this will now throw a TypeError instead. This is covered by the new WPTs.

Developers who want to create a ReadableStream from a string should update their code to either:

  • ReadableStream.from(["abc"]) for a stream with a single chunk "abc"
  • ReadableStream.from([..."abc"]) for a stream with three chunks "a", "b", "c"

Supersedes #1310. (Thanks to @lucacasonato for getting this started!)

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

@MattiasBuelens
Copy link
Copy Markdown
Collaborator Author

The spec text doesn't build yet, because I'm waiting for a new release of Bikeshed that includes speced/bikeshed#3297.

You can already build it locally by manually updating the widlparser dependency:

pipx install bikeshed
pipx inject bikeshed --force widlparser==1.5.0
make local

@MattiasBuelens MattiasBuelens requested review from alrra, annevk and saschanaz and removed request for alrra May 1, 2026 13:56
@MattiasBuelens MattiasBuelens force-pushed the rs-from-async-sequence branch from d78c683 to c7762c2 Compare May 1, 2026 14:23
Comment thread index.bs
their constructor steps.

<div algorithm="create a ReadableStream from an async sequence">
To <dfn export lt="create from async sequence|create from an async sequence" for="ReadableStream">create</dfn>
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.

@lucacasonato Would this work for whatwg/fetch#1291?

@MattiasBuelens MattiasBuelens force-pushed the rs-from-async-sequence branch from c7762c2 to 68ae88a Compare May 1, 2026 14:30
Copy link
Copy Markdown
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

Modulo green CI. WebKit supports this change. cc @youennf

@MattiasBuelens MattiasBuelens force-pushed the rs-from-async-sequence branch 3 times, most recently from 8bb3507 to 68ae88a Compare May 5, 2026 05:48
@MattiasBuelens MattiasBuelens force-pushed the rs-from-async-sequence branch from 68ae88a to 7511a41 Compare May 5, 2026 17:38
@MattiasBuelens MattiasBuelens force-pushed the rs-from-async-sequence branch from 68ae88a to 5ca9d87 Compare May 5, 2026 17:42
@MattiasBuelens
Copy link
Copy Markdown
Collaborator Author

CI is (finally) green. Turns out Bikeshed needed to be updated across quite a few tools and services. 😅

Does Chromium and/or Gecko support this change? @ricea perhaps?

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants