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

Possible pipeline deadlock #39005

Closed
ronag opened this issue Jun 11, 2021 · 1 comment
Closed

Possible pipeline deadlock #39005

ronag opened this issue Jun 11, 2021 · 1 comment

Comments

@ronag
Copy link
Member

ronag commented Jun 11, 2021

From reviewing the code I notice the following:

https://github.com/nodejs/node/blob/master/lib/internal/streams/pipeline.js#L116

    for await (const chunk of iterable) {
      if (!writable.write(chunk)) {
        if (writable.destroyed) return;
        await EE.once(writable, 'drain');
      }
    }

In particular the following:

await EE.once(writable, 'drain');

writable might never emit 'drain' or 'error', instead only 'close' might be emitted. A bit unfortunate but that's how streams work.

@ronag
Copy link
Member Author

ronag commented Jun 11, 2021

@mcollina I think we might need to change this to:

await Promise.race([
  await EE.once(writable, 'drain'),
  EE.once(writable, 'close')
])

Which is a bit slow :/

ronag added a commit to nxtedition/node that referenced this issue Jun 11, 2021
ronag added a commit to nxtedition/node that referenced this issue Jun 11, 2021
jasnell pushed a commit that referenced this issue Jun 14, 2021
Refs: #39005

PR-URL: #39006
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
danielleadams pushed a commit that referenced this issue Jun 15, 2021
Refs: #39005

PR-URL: #39006
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
danielleadams pushed a commit that referenced this issue Jun 17, 2021
Refs: #39005

PR-URL: #39006
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@ronag ronag closed this as completed Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant