Contact emails

mattias.buel...@gmail.com

Explainer

https://github.com/whatwg/streams/blob/main/readable-stream-async-iteration-explainer.md

Specification

https://streams.spec.whatwg.org/#rs-asynciterator

Summary

The streams APIs provide ubiquitous, interoperable primitives for creating, 
composing, and consuming streams of data. This change adds support for the 
async iterable protocol to the ReadableStream API, enabling readable 
streams to be used as the source of for await...of loops.


Blink component

Blink>Network>StreamsAPI 
<https://bugs.chromium.org/p/chromium/issues/list?q=component:Blink%3ENetwork%3EStreamsAPI>

Motivation

To consume a ReadableStream, developers currently acquire a reader and 
repeatedly call read(). By adding support for the async iterable protocol, 
web developers will be able to use the much simpler for await...of syntax 
to loop over all chunks of a ReadableStream.

Web developers are already using polyfills to async-iterate over a 
ReadableStream. These polyfills usually work fine, but might not handle all 
edge cases correctly (such as when the stream errors during a read, or 
releasing the reader's lock when breaking out of a for await...of loop).


Initial public proposal

None

Search tags

streams <https://chromestatus.com/features#tags:streams>

TAG review

None

TAG review status

Not applicable. (This is a small feature with a mature specification that's 
already shipping in Firefox.)

Risks

Interoperability and Compatibility

Low risk. The Streams API has already been standardised for a long time. 
Async iteration is already supported in one other browser (Firefox) and 
several JavaScript runtimes (Node.js, Deno, bun).


Gecko: Shipped/Shipping (
https://bugzilla.mozilla.org/show_bug.cgi?id=1525852) Shipped in Firefox 110

WebKit: No signal (https://github.com/WebKit/standards-positions/issues/319)

Web developers: Positive (https://github.com/whatwg/streams/issues/778) 
Developers already expect this to work, and often use a polyfill.

Other signals:

Activation

Async iteration can be feature detected by checking the existence of 
`ReadableStream.prototype.values`. Various polyfills already exist in the 
wild. (e.g. https://jakearchibald.com/2017/async-iterators-and-generators/)


WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that 
it has potentially high risk for Android WebView-based applications?

None


Debuggability

No special support needed. The JavaScript debugger is already sufficiently 
capable of handling for await...of loops.


Is this feature fully tested by web-platform-tests 
<https://chromium.googlesource.com/chromium/src/+/main/docs/testing/web_platform_tests.md>
?

Yes

https://wpt.fyi/results/streams/readable-streams/async-iterator.any.html


Flag name on chrome://flags

None

Finch feature name

ReadableStreamAsyncIterable

Requires code in //chrome?

False

Tracking bug

https://issues.chromium.org/issues/40612900

Estimated milestones

No milestones specified


Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5143121161879552

This intent message was generated by Chrome Platform Status 
<https://chromestatus.com/>.

-- 
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to blink-dev+unsubscr...@chromium.org.
To view this discussion on the web visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/b1438dfd-ec71-4e18-b34d-0213aff6250cn%40chromium.org.

Reply via email to