-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
stream: fix error handling with async iteration #20329
Conversation
Fix an issue when an error was emitted by the stream before `iterator.next()` is called.
read() {} | ||
}) | ||
|
||
let err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, missing semicolon. Please run make lint
:)
} catch (e) { | ||
err = e; | ||
} | ||
assert.strictEqual(err.message, 'kaboom'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assert that we have reference equality and assert Node doesn't mutate the error (basically define the error above and assert that strictEqual
on the instance?
Also - you can use the newly added assert.rejects
(although no obligation)
console.log('call next() after error'); | ||
const readable = new Readable({ | ||
read() {} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, missing semicolon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all - good to see you here.
Second - thank you for doing this - any feedback about the Symbol.asyncIterator
feature is greatly appreciated.
Also - Good catch! I've left some comments. You're welcome to address them (and maybe amend the PR description to meet our standard format). If you won't a collaborator would do this for you when landing it.
Thanks for your welcome and comments 😃 I've fixed the code accordingly, but I still cannot run the tests so I'm not sure it works 😜 |
@julien-f what issue are you having with running the tests? If you're having trouble running the tests let's:
We really want to avoid having contributors climb technical barriers in orders to contribute. In addition, I've kicked a CI for it: https://ci.nodejs.org/job/node-test-pull-request/14524/console |
@benjamingr No particular issues, I simply have never compiled Node on my machine and I don't have time to figure it out for the moment. |
There seem to be some lint errors in the tests: https://ci.nodejs.org/job/node-test-linter/18544/console |
On it, sorry for this, I missed it 😳 |
Don't worry about it, new CI: https://ci.nodejs.org/job/node-test-pull-request/14525/console Also note that while cloning and building Node sounds like a lot of work - it's actually not nearly as complicated as it appears. Basically:
Assuming you have Python (comes built in on mac), git (which is common for developers) and a C++ compiler (which is an |
Ok, I successfully built it with |
CI is green, what's going to happen next is that this will sit for 72 hours so collaborators have a chance to review it and then we'll land it if no one objects. (since it already has one approval). Any future work on async iterator support would be appreciated :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Added [dont-land-on] labels for versions of Node that don't support async iterators. |
Landed in 9c48926 🎉 |
Fix an issue when an error was emitted by the stream before `iterator.next()` is called. PR-URL: nodejs#20329 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Welcome to the Node contributor ranks @julien-f ! Any follow-up work that you'd like to work up with in the async iterator space would be very appreciated and if you need any help or resources to better contribute by all means please reach out. |
Fix an issue when an error was emitted by the stream before `iterator.next()` is called. PR-URL: #20329 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Fix an issue when an error was emitted by the stream before
iterator.next()
is called.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesI don't have the time to figure out how to run the tests, sorry.
/cc @mcollina