Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

julien-f
Copy link
Contributor

Fix an issue when an error was emitted by the stream before
iterator.next() is called.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

I don't have the time to figure out how to run the tests, sorry.

/cc @mcollina

Fix an issue when an error was emitted by the stream before
`iterator.next()` is called.
read() {}
})

let err
Copy link
Member

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');
Copy link
Member

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() {}
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, missing semicolon

Copy link
Member

@benjamingr benjamingr left a 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.

@benjamingr benjamingr added stream Issues and PRs related to the stream subsystem. promises Issues and PRs related to ECMAScript promises. labels Apr 26, 2018
@julien-f
Copy link
Contributor Author

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 😜

@benjamingr
Copy link
Member

@julien-f what issue are you having with running the tests?

If you're having trouble running the tests let's:

  • figure out what the issue running the tests is
  • file an issue to fix that so that other people don't have it

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

@julien-f
Copy link
Contributor Author

@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.

@benjamingr
Copy link
Member

There seem to be some lint errors in the tests: https://ci.nodejs.org/job/node-test-linter/18544/console

@julien-f
Copy link
Contributor Author

On it, sorry for this, I missed it 😳

@benjamingr
Copy link
Member

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:

git clone https://github.com/nodejs/node
cd node
./configure
make -j4

Assuming you have Python (comes built in on mac), git (which is common for developers) and a C++ compiler (which is an xcode-select --install away if you've never installed it)
We have detailed instructions here

@julien-f
Copy link
Contributor Author

Ok, I successfully built it with ./configure --openssl-no-asm.

@benjamingr
Copy link
Member

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 :)

@benjamingr benjamingr added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 26, 2018
Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@benjamingr
Copy link
Member

Added [dont-land-on] labels for versions of Node that don't support async iterators.

@BridgeAR
Copy link
Member

Landed in 9c48926 🎉

@BridgeAR BridgeAR closed this Apr 29, 2018
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Apr 29, 2018
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>
@benjamingr
Copy link
Member

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.

@julien-f julien-f deleted the stream-async-iteration branch April 30, 2018 08:38
MylesBorins pushed a commit that referenced this pull request May 4, 2018
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>
@MylesBorins MylesBorins mentioned this pull request May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. promises Issues and PRs related to ECMAScript promises. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants