Skip to content

Commit 095cd5f

Browse files
committed
stream: reject primitive values in ReadableStream.from
Reject non-object inputs before looking up iterator methods in ReadableStream.from(). This matches the Web IDL async sequence conversion and prevents primitive strings from being accepted through property-access boxing. This fixes the WPT test: "ReadableStream.from throws on invalid iterables; specifically a string". Refs: https://webidl.spec.whatwg.org/#es-sequence Signed-off-by: Jeong SeokChan <starp321@naver.com>
1 parent 4605cf5 commit 095cd5f

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

lib/internal/webstreams/readablestream.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,11 @@ function createReadableStreamState() {
14381438
}
14391439

14401440
function readableStreamFromIterable(iterable) {
1441+
if (iterable === null ||
1442+
(typeof iterable !== 'object' && typeof iterable !== 'function')) {
1443+
throw new ERR_ARG_NOT_ITERABLE(iterable);
1444+
}
1445+
14411446
let stream;
14421447
const iteratorGetter = iterable[SymbolAsyncIterator] ?? iterable[SymbolIterator];
14431448
if (iteratorGetter == null || typeof iteratorGetter !== 'function') {

test/wpt/status/streams.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
"readable-streams/cross-realm-crash.window.js": {
99
"skip": "Browser-specific test"
1010
},
11-
"readable-streams/from.any.js": {
12-
"fail": {
13-
"expected": [
14-
"ReadableStream.from throws on invalid iterables; specifically a string"
15-
]
16-
}
17-
},
1811
"readable-streams/owning-type-message-port.tentative.any.js": {
1912
"fail": {
2013
"note": "Readable streams with type owning are not yet supported",

0 commit comments

Comments
 (0)