| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@Trott flaky V8 compile, please restart? |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
| streams using async iterators any errors emitted after `'end'` or `'close'` | |
| streams using async iterators, any errors emitted after `'end'` or `'close'` |
Sorry, something went wrong.
|
@nodejs/streams |
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
|
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? |
Sorry, something went wrong.
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 'readable' / read() internally). An iterator does not use .pipe(), so there is no multiple destination logic in there. |
Sorry, something went wrong.
Hence, should we throw if a secondary iterator is created? Also possibly add a note in the docs? |
Sorry, something went wrong.
|
Updated description in accordance with @mcollina's previous suggestion. |
Sorry, something went wrong.
|
Throwing if there's an attempt to create a second iterator would make sense to me. What do you think @mcollina? |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
|
@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? |
Sorry, something went wrong.
Sorry, something went wrong.
| ``` | ||
|
|
||
| Async iterators register a permanent error handler on the stream to prevent any | ||
| unhandled post-destroy errors. |
There was a problem hiding this comment.
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?
Sorry, something went wrong.
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 <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Clarifies that creating multiple async iterators from the same stream can lead to event listener leak. PR-URL: #28997 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
| Back | FazBrowse Home | New Git URL |
Clarifies that creating multiple async iterators from the same stream can lead to event listener leak.
Checklist