Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
doc: clarify async iterator leak#28997
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
8a6b51d to 5fb5109Compareronag commented Aug 6, 2019
@Trott flaky V8 compile, please restart? |
nodejs-github-bot commented Aug 7, 2019
doc/api/stream.md Outdated
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.
| streams using async iterators any errors emitted after `'end'` or `'close'` | |
| streams using async iterators, any errors emitted after `'end'` or `'close'` |
Trott commented Aug 7, 2019
@nodejs/streams |
mcollina left a comment
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.
I don't think we should land this change.
When a stream is async iterated it will always exit the iteration in a destroyed state, i.e. break or throw will call destroy() on the stream. As a result, we cannot create multiple streams one after the other.
Moreover, creating multiple parallel AsyncIterators out of the same stream is problematic and should not be done: the behavior is going to be very unpredictable (which of the two iterators will get the data? only one will).
What should be documented is that, because it's left in a destroyed state, there will be a 'error' event handler attached to prevent further exceptions to crash the process.
ronag commented Aug 7, 2019 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Isn’t it possible to create multiple iterators? i.e when using the iterator API directly and not through a for loop? Should we maybe throw if a second iterative is created? |
mcollina commented Aug 7, 2019
The semantics of that are currently not what somebody is going to expect. The two iterators are going to compete for the chunks (as they use |
ronag commented Aug 7, 2019
Hence, should we throw if a secondary iterator is created? Also possibly add a note in the docs? |
ronag commented Aug 7, 2019
Updated description in accordance with @mcollina's previous suggestion. |
jasnell commented Aug 7, 2019
Throwing if there's an attempt to create a second iterator would make sense to me. What do you think @mcollina? |
mcollina left a comment
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.
LGTM
mcollina commented Aug 9, 2019
ronag commented Aug 12, 2019 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@Trott: This fails because I didn't rebase master. However, since it's a simple doc change I don't think it's worth a rebase? |
Trott commented Aug 12, 2019
| ``` | ||
| Async iterators register a permanent error handler on the stream to prevent any | ||
| unhandled post-destroy errors. |
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.
Not sure that what I"m about to suggest is a good idea, so I'll defer to everyone else's judgment:
Is it worth re-wording to make it clear that this means the destroy() method?
| unhandled post-destroy errors. | |
| unhandled errors after `destroy()` executes. |
I'm not sure that's an improvement to be honest, but maybe?
Trott commented Aug 12, 2019
Landed in d7a4ace |
Clarifies that creating multiple async iterators from the same stream can lead to event listener leak. PR-URL: nodejs#28997 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Clarifies that creating multiple async iterators from the same stream can lead to event listener leak. PR-URL: #28997 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Clarifies that creating multiple async iterators from the same stream can lead to event listener leak.
Checklist