[whatwg/streams] Use `async_sequence` in `ReadableStream.from` (PR #1372)

Replace our manual async iterator logic with the new Web IDL `async_sequence<T>` type and its associated operations (added in https://github.com/whatwg/webidl/pull/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]`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/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 https://github.com/whatwg/streams/pull/1310. (Thanks to @lucacasonato for getting this started!)

- [ ] At least two implementers are interested (and none opposed):
   * …
   * …
- [ ] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
   * … <!-- If these tests are tentative, link a PR to make them non-tentative. -->
- [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed:
   * Chromium: …
   * Gecko: …
   * WebKit: …
   * Deno: …
   * Node.js: …
- [ ] [MDN issue](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) is filed: …
- [ ] The top of this comment includes a [clear commit message](https://github.com/whatwg/meta/blob/main/COMMITTING.md) to use. <!-- If you created this PR from a single commit, Github copied its message. Otherwise, you need to add a commit message yourself. -->

(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)


<!--
    This comment and the below content is programmatically generated.
    You may add a comma-separated list of anchors you'd like a
    direct link to below (e.g. #idl-serializers, #idl-sequence):

    Don't remove this comment or modify anything below this line.
    If you don't want a preview generated for this pull request,
    just replace the whole of this comment's content by "no preview"
    and remove what's below.
-->
***

### :boom: Error: 422 Unprocessable Entity :boom: ###

[PR Preview](https://github.com/tobie/pr-preview#pr-preview) failed to build. _(Last tried on May 1, 2026, 1:42 PM UTC)_.

<details>
<summary>More</summary>


PR Preview relies on a number of web services to run. There seems to be an issue with the following one:

:rotating_light: [Spec Generator](https://www.w3.org/publications/spec-generator/) - Spec Generator is the web service used to build bikeshed/ReSpec specs

:link: [Related URL](https://www.w3.org/publications/spec-generator/?type=bikeshed-spec&output=html&url=https%3A%2F%2Fraw.githubusercontent.com%2FMattiasBuelens%2Fstreams%2F778c2370205364348ae3c59e3c0e84463577d4e3%2Findex.bs&force=1&md-status=LS-PR&md-Text-Macro=PR-NUMBER%201372)

**Error output:**

```json
[
    {
        "lineNum": "487",
        "messageType": "fatal",
        "text": "skipped: \"static ReadableStream from(async_sequence<any> asyncIterable)\""
    },
    {
        "lineNum": null,
        "messageType": "failure",
        "text": "Did not generate, due to errors exceeding the allowed error level."
    }
]
```

_This seems to be an issue with the [Spec Generator](https://www.w3.org/publications/spec-generator/) service. PR Preview doesn't manage this service and so has no control over it. If you've identified an issue with it, you can [report the issue to the maintainers of Spec Generator](https://github.com/w3c/spec-generator/issues/new) directly. Please be courteous. Thank you!_

_If you don't have enough information above to solve the error by yourself or if the issue doesn't seem related to Spec Generator, you can [file an issue with PR Preview](https://github.com/tobie/pr-preview/issues/new?title=Unidentified%20Error&body=See%20whatwg/streams%231372.)._

</details>

You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/streams/pull/1372

-- Commit Summary --

  * Use `async iterable` webidl type in ReadableStream.from
  * Wire through reason
  * re-add comment
  * review comment
  * remove export
  * Merge branch 'main' into rs-from-async-sequence
  * Switch to `async_sequence`
  * Update reference implementation
  * Update spec text

-- File Changes --

    M index.bs (41)
    M reference-implementation/lib/ReadableStream.webidl (2)
    M reference-implementation/lib/abstract-ops/readable-streams.js (36)
    M reference-implementation/package.json (2)

-- Patch Links --

https://github.com/whatwg/streams/pull/1372.patchhttps://github.com/whatwg/streams/pull/1372.diff
-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1372
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/pull/1372@github.com>

Received on Friday, 1 May 2026 13:43:03 UTC