Skip to content

Commit fd2ff95

Browse files
committed
fix: validate ReadableStream.from iterator objects
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
1 parent 5f92b6d commit fd2ff95

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

lib/internal/webstreams/readablestream.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,9 @@ function readableStreamFromIterable(iterable) {
13651365
throw new ERR_ARG_NOT_ITERABLE(iterable);
13661366
}
13671367
const iterator = FunctionPrototypeCall(iteratorGetter, iterable);
1368+
if (typeof iterator !== 'object' || iterator === null) {
1369+
throw new ERR_INVALID_STATE.TypeError('The iterator method must return an object');
1370+
}
13681371
const startAlgorithm = nonOpStart;
13691372

13701373
async function pullAlgorithm() {

test/wpt/status/streams.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +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-
"note": "does not synchronously validate that the value returned by @@iterator/@@asyncIterator is an object",
14-
"expected": [
15-
"ReadableStream.from throws on invalid iterables; specifically an object with an @@iterator method returning a non-object",
16-
"ReadableStream.from throws on invalid iterables; specifically an object with an @@asyncIterator method returning a non-object"
17-
]
18-
}
19-
},
2011
"readable-streams/owning-type-message-port.any.js": {
2112
"fail": {
2213
"note": "Readable streams with type owning are not yet supported",

0 commit comments

Comments
 (0)