Repository navigation
ReadableStream.from({}) returns confusing error #53819
Description
Activity
Note there is another apparent bug here. For some reason,
FunctionPrototypeCallis reporting its own name instead of its first argument. That is, the faulting line should probably print an error that says: "'method' is not a function"const iterator = FunctionPrototypeCall(method, obj);
Edit: reported issue in V8 https://issues.chromium.org/issues/352528966
Reacted by jakecastelliThe way I see it, the error message content displayed is a V8 bug, but the fact that it even got to that error (and not a validation error) may be an issue with Node.js.
Reacted by Dan Rose- addedstreamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.web streamsIssues and PRs related to the Web Streams API.Issues and PRs related to the Web Streams API.and removedstreamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
on Jul 12, 2024 Had a quick look, I think something like this would prevent it:
diff --git a/lib/internal/webstreams/util.js b/lib/internal/webstreams/util.js index cce67d5b04..2b043f987c 100644 --- a/lib/internal/webstreams/util.js +++ b/lib/internal/webstreams/util.js @@ -243,6 +243,10 @@ function getIterator(obj, kind = 'sync', method) { } } + if (method === undefined) { + throw new ERR_INVALID_STATE.TypeError('The object is not iterable'); + } + const iterator = FunctionPrototypeCall(method, obj);
@debadree25 any idea?
I believe that method is a 1-1 mapping of https://tc39.es/ecma262/#sec-getiterator and we are missing Step 1.b.ii and Step 3. so i think you diff should solve it @jakecastelli
Thanks! I am not too familiar with webstream and wpt (roughly know the idea) do we need to add a test for this in our test/parallel or should this test be ideally in wpt upstream.
I think test/parallel should be fine
Reacted by jakecastelliI believe that method is a 1-1 mapping of https://tc39.es/ecma262/#sec-getiterator and we are missing Step 1.b.ii and Step 3. so i think you diff should solve it
It seems to have started from
GetIteratorbut it has an extra parameter and seems to have absorbedGetIteratorFromMethod. The recursive call here ofgetIteratorseems to be a slight code smell.- added a commit that references this issue
on Aug 1, 2024 - added a commit that references this issue
on Aug 14, 2024 - added a commit that references this issue
on Sep 21, 2024 - added a commit that references this issue
on Oct 2, 2024
Version
v22.4.1
Platform
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
It should show a more descriptive error message. Maybe "value is not iterable".
What do you see instead?
Additional information
No response