-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
Currently iterator helpers throw type errors on first iteration - they should likely do so synchronously.
For example:
Readable.from([1]).map(1); // returns a stream, for...awaiting it will throw the error
Instead I think we should throw synchronously, which is what I believe the spec says.
A fix would be to take the code in operators.js that does validations that is in an async generator and wrap it so that it does those validations in a function called before the async generator.
So instead of:
async function* map(...) {
validateFoo(...);
}
We'd do:
function map(...) { // not async to throw synchronously
validateFoo(...);
return async function*() {
}();
}
The test at test-stream-map would similarly need to be updated from rejecting asynchronously on iteration to throwing synchronously. I've opened an issue in the iterator helper proposal to be sure.
That's my understanding here: https://tc39.es/proposal-iterator-helpers/#sec-asynciteratorprototype.map
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.