Repository navigation
Tracking bug and discussion for asynchronous iteration in Node.js core #15709
Description
Activity
- addeddiscussIssues opened for discussion and feedback.Issues opened for discussion and feedback.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.readlineIssues and PRs related to the built-in readline module.Issues and PRs related to the built-in readline module.streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
on Oct 1, 2017 Personally, I would look forward to a core way to read and process big files line by line in async/await functions without complicated Promise chains in event callbacks.
I understand this is not the main purpose of streams, but everybody loves
fsorhttpanyway, so this is just a reminder to not forgetreadline.Reacted by J. S. Choi- changed the title
[-]Traking bug and discussion for asynchronous iteration in Node.js core[/-][+]Tracking bug and discussion for asynchronous iteration in Node.js core[/+]on Oct 1, 2017 I'm not super familiar with async iterators but this seems like something we'd definitely want to investigate further.
Reacted by J. S. ChoiAsyncIterator landed in Chrome and V9 will likely ship support. @nodejs/streams @nodejs/collaborators
I would love it if this issue made it to TSC agenda and discussed at the next meeting - I think adding experimental
Symbol.asyncIteratorsupport to streams behind a flag while explaining they don't perform as well as streams at the moment might be a good idea.Reacted by snek and J. S. ChoiI don't know if I'll have time for a pull request but if somebody wants to use the module I wrote as the basis for adding them to streams you have my permission to do so without worrying about the license.
I don't think that placing them under a flag is helpful. I would just emit an experimental warning when using them for the first time.
Reacted by Jan Olaf Martin, Myles Borins and Benjamin Gruenbaum@mcollina you're right, an experimental morning should be sufficient.
I'm working on an implementation of this, and it is not clear when
asyncIterator.throw(e)is called.I've been playing with this a little bit in the fs promises implementation, specifically in a promise-based
readFile()implementation and I have to say that using the async iterator works rather well. I'll be pushing the code up to a branch a bit later today.Reacted by J. S. ChoiReacted by Jonny Eskew2 remaining items
- added a commit that references this issue
on Dec 19, 2017 Hey. I want to chip in for any Node.js users like myself, playing along at home, about how to use async generators in Node.js: that information was a little scattered, and I wasn't sure what the status was myself.
- Node versions 8.3 and above seem to have async iteration support! (Wow! That's way more support than I thought!)
All versions of Node that do support async iteration requireedit: Node v10 and up has async iteration on by default, Node v8.3+ requires--harmony_async_iterationto get the feature.--harmony_async_iteration.- I tested with this sample script:
async function * answers(){ yield Promise.resolve(42); }; (async function universe(){ for await (var answer of answers()){ console.log(answer) } })()Thank you Node team and V8 implementer Caitlin Potter. This is such a great improvement to JavaScript.
Reacted by Vse Mozhe Buty, Mauve Signweaver, Alf Eaton and Adam- added a commit that references this issue
on Jul 27, 2026
Asynchronous iteration has landed in V8 6.3 , so we can have it in Node.js v9 at the end of the year.
There are some plans to implement a stream version based on this feature. Since node-eps seems to be archived, maybe it is worth to have an issue for this in the core repository.
Refs:
https://github.com/tc39/proposal-async-iteration
https://tc39.github.io/proposal-async-iteration/
https://bugs.chromium.org/p/v8/issues/detail?id=5855
https://ponyfoo.com/articles/javascript-asynchronous-iteration-proposal
http://2ality.com/2016/10/asynchronous-iteration.html
https://jakearchibald.com/2017/async-iterators-and-generators/
nodejs/CTC#53
nodejs/readable-stream#254
tc39/proposal-async-iteration#74
nodejs/promises#31 (and nodejs/promises#31 (comment))
https://github.com/calvinmetcalf/async-iter-stream