-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iterator helpers throw the error too late #41648
Comments
If you want to open an issue without using a template, you can go to https://github.com/nodejs/node/issues/new |
@targos TIL, thanks! |
I'm opening an issue rather than a fix since I think this issue is a good place for people other than myself and ronag to get involved with the iterator-helpers initiative :) |
Confirmed the behavior should be to throw synchronously with the proposal - so this is a bug that should be fixed. |
Is the intention for stream methods to match the iterator helpers interface? |
@ljharb the intention to add most iterator helper proposal methods to the node streams interface. I intend Node to pass the tc39 tests as much as possible (read: all of them) and would strongly prefer not to move these methods out of "experimental" until the proposal gets to (at least) stage 3. There are some divergences that exist (for example - tc39/proposal-iterator-helpers#162 which is why I asked for future-compatibility there). In addition - if/when the spec changes I believe Node.js should change its implementation to align. |
(This is a good area to be involved in by the way!) |
@benjamingr I'll happily take this, does seem like a great starting point to get involved :) |
@iMoses great, let me know if you need help getting started - the sooner we land this the better since these APIs are shipping :) |
`streams/operators/map` is no longer a generator function, instead it returns a called generator so that validation can happen synchronously and not wait for the first iteration Fixes: nodejs#41648
`streams/operators/map` is no longer a generator function, instead it returns a called generator so that validation can be synchronous and not wait for the first iteration Fixes: nodejs#41648
`streams/operators/map` is no longer a generator function, instead it returns a called generator so that validation can be synchronous and not wait for the first iteration Fixes: nodejs#41648
is no longer a generator function, instead it returns a called generator so that validation can be synchronous and not wait for the first iteration Fixes: nodejs#41648
is no longer a generator function, instead it returns a called generator so that validation can be synchronous and not wait for the first iteration Fixes: nodejs#41648
is no longer a generator function, instead it returns a called generator so that validation can be synchronous and not wait for the first iteration Fixes: nodejs#41648
is no longer a generator function, instead it returns a called generator so that validation can be synchronous and not wait for the first iteration Fixes: #41648 PR-URL: #41652 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
is no longer a generator function, instead it returns a called generator so that validation can be synchronous and not wait for the first iteration Fixes: nodejs#41648 PR-URL: nodejs#41652 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
is no longer a generator function, instead it returns a called generator so that validation can be synchronous and not wait for the first iteration Fixes: #41648 PR-URL: #41652 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
is no longer a generator function, instead it returns a called generator so that validation can be synchronous and not wait for the first iteration Fixes: nodejs#41648 PR-URL: nodejs#41652 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
Currently iterator helpers throw type errors on first iteration - they should likely do so synchronously.
For example:
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:
We'd do:
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
The text was updated successfully, but these errors were encountered: