Closed rotu closed 3 months ago
Note there is another apparent bug here. For some reason, FunctionPrototypeCall
is 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
The 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.
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
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
It seems to have started from GetIterator
but it has an extra parameter and seems to have absorbed GetIteratorFromMethod
. The recursive call here of getIterator
seems to be a slight code smell.
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