GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: reset awaitDrain after manual .resume() by addaleax · Pull Request #7160 · nodejs/node

Conversation

@addaleax

@addaleax addaleax commented Jun 5, 2016

Copy link
Copy Markdown
Member
Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • the commit message follows commit guidelines
Affected core subsystem(s)

stream

Description of change

Reset the readableState.awaitDrain counter after manual calls to .resume().

What might happen otherwise is that a slow consumer at the end of the pipe could end up stalling the piping in the following scenario:

  1. The writable stream indicates that its buffer is full.
  2. This leads the readable stream to pause() and increase its awaitDrain counter, which will be decreased by the writable’s next drain event.
  3. Something calls .resume() manually.
  4. The readable continues to pipe to the writable, but once again the writable stream indicates that the buffer is full.
  5. The awaitDrain counter is thus increased again, but since it has now been increased twice for a single piping destination, the next drain event will not be able to reset awaitDrain to zero.
  6. The pipe is stalled and no data is passed along anymore.

The solution in this commit is to reset the awaitDrain counter to zero when resume() is called.

Fixes: #7159

This bug is has been around at least since 0.12, and I don’t currently know why it never popped up before #2325 when the awaitDrain mechanism worked like it does today.

/cc @nodejs/streams

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@addaleax
stream: reset awaitDrain after manual .resume()
71a0253
Reset the `readableState.awaitDrain` counter after manual calls to
`.resume()`.

What might happen otherwise is that a slow consumer at the end of the
pipe could end up stalling the piping in the following scenario:

1. The writable stream indicates that its buffer is full.
2. This leads the readable stream to `pause()` and increase its
   `awaitDrain` counter, which will be decreased by the writable’s next
   `drain` event.
3. Something calls `.resume()` manually.
4. The readable continues to pipe to the writable, but once again
   the writable stream indicates that the buffer is full.
5. The `awaitDrain` counter is thus increased again, but since it has
   now been increased twice for a single piping destination, the next
   `drain` event will not be able to reset `awaitDrain` to zero.
6. The pipe is stalled and no data is passed along anymore.

The solution in this commit is to reset the `awaitDrain` counter to
zero when `resume()` is called.

Fixes: nodejs#7159
@addaleax addaleax added the stream Issues and PRs related to Node.js streams. label Jun 5, 2016
@addaleax addaleax mentioned this pull request Jun 5, 2016
'close' event for spawn() isn't emitted under unknown conditions #7159
Closed
@addaleax

addaleax commented Jun 5, 2016

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-commit/3655/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax added the lts-watch-v4.x label Jun 5, 2016
@mcollina

mcollina commented Jun 6, 2016

Copy link
Copy Markdown
Member

I think this should be ok to backport, but we should probably check CIGTM before that. cc @calvinmetcalf

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jun 6, 2016

Copy link
Copy Markdown
Member

LGTM if @nodejs/streams folks are happy.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax mentioned this pull request Jun 7, 2016
child-process: data loss with piped stdout #7184
Closed
@petrosagg petrosagg mentioned this pull request Jun 7, 2016
Fix child process stdio data loss with slow piped consumers #7185
Closed
3 of 4 tasks
@MylesBorins MylesBorins self-assigned this Jun 8, 2016
@MylesBorins MylesBorins mentioned this pull request Jun 8, 2016
Regression in v4.4.5 nodejs/Release#110
Closed
@petrosagg petrosagg mentioned this pull request Jun 10, 2016
Add two child-process stdio flush tests #7257
Closed
2 of 3 tasks
@addaleax addaleax mentioned this pull request Jun 12, 2016
Change in stream behaviour in Node 4.4.5 #7278
Closed
@addaleax

addaleax commented Jun 13, 2016

Copy link
Copy Markdown
Member Author

@thealphanerd since you self-assigned this… anything in particular you’d like to see before landing?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@calvinmetcalf

calvinmetcalf commented Jun 13, 2016

Copy link
Copy Markdown
Contributor

Doesn't look to be anything to controversial from my perspective

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@calvinmetcalf calvinmetcalf closed this Jun 13, 2016
@MylesBorins MylesBorins reopened this Jun 13, 2016
@MylesBorins

MylesBorins commented Jun 13, 2016

Copy link
Copy Markdown
Contributor

@calvinmetcalf I'm assuming you did not mean to close this 😄

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MylesBorins

MylesBorins commented Jun 13, 2016

Copy link
Copy Markdown
Contributor

@addaleax Nothing I need to see before landing, assigned to myself to keep an eye on it for LTS

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MylesBorins MylesBorins mentioned this pull request Jun 13, 2016
Streams Regression in v4.x nodejs/Release#112
Closed
@calvinmetcalf

calvinmetcalf commented Jun 13, 2016

Copy link
Copy Markdown
Contributor

@thealphanerd you are correct

sorry foks

MylesBorins reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mafintosh

mafintosh commented Jun 13, 2016

Copy link
Copy Markdown
Member

as long as @mcollina is happy i'm happy so 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax added a commit that referenced this pull request Jun 13, 2016
@addaleax
stream: reset awaitDrain after manual .resume()
e2e615e
Reset the `readableState.awaitDrain` counter after manual calls to
`.resume()`.

What might happen otherwise is that a slow consumer at the end of the
pipe could end up stalling the piping in the following scenario:

1. The writable stream indicates that its buffer is full.
2. This leads the readable stream to `pause()` and increase its
   `awaitDrain` counter, which will be decreased by the writable’s next
   `drain` event.
3. Something calls `.resume()` manually.
4. The readable continues to pipe to the writable, but once again
   the writable stream indicates that the buffer is full.
5. The `awaitDrain` counter is thus increased again, but since it has
   now been increased twice for a single piping destination, the next
   `drain` event will not be able to reset `awaitDrain` to zero.
6. The pipe is stalled and no data is passed along anymore.

The solution in this commit is to reset the `awaitDrain` counter to
zero when `resume()` is called.

Fixes: #7159
PR-URL: #7160
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@addaleax

addaleax commented Jun 13, 2016

Copy link
Copy Markdown
Member Author

Landed in e2e615e, thanks for the reviews and comments, everyone!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax closed this Jun 13, 2016
@addaleax
addaleax deleted the fix-7159 branch June 13, 2016 21:58
evanlucas pushed a commit that referenced this pull request Jun 16, 2016
@addaleax @evanlucas
stream: reset awaitDrain after manual .resume()
9c6b69e
Reset the `readableState.awaitDrain` counter after manual calls to
`.resume()`.

What might happen otherwise is that a slow consumer at the end of the
pipe could end up stalling the piping in the following scenario:

1. The writable stream indicates that its buffer is full.
2. This leads the readable stream to `pause()` and increase its
   `awaitDrain` counter, which will be decreased by the writable’s next
   `drain` event.
3. Something calls `.resume()` manually.
4. The readable continues to pipe to the writable, but once again
   the writable stream indicates that the buffer is full.
5. The `awaitDrain` counter is thus increased again, but since it has
   now been increased twice for a single piping destination, the next
   `drain` event will not be able to reset `awaitDrain` to zero.
6. The pipe is stalled and no data is passed along anymore.

The solution in this commit is to reset the `awaitDrain` counter to
zero when `resume()` is called.

Fixes: #7159
PR-URL: #7160
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@evanlucas evanlucas mentioned this pull request Jun 16, 2016
v6.2.2 proposal #7323
Merged
abresas added a commit to balena-io-modules/open-balena-base that referenced this pull request Jun 20, 2016
@abresas
move to nodejs v6.2.2
7194190
fixes streams error nodejs/node#7160
abresas added a commit to balena-io-modules/open-balena-base that referenced this pull request Jun 20, 2016
@abresas
move to nodejs v6.2.2
4e06ca1
fixes streams error nodejs/node#7160
@abresas abresas mentioned this pull request Jun 20, 2016
move to nodejs v6.2.2 balena-io-modules/open-balena-base#15
Merged
@MylesBorins MylesBorins added land-on-v4.x and removed lts-watch-v4.x labels Jun 23, 2016
MylesBorins pushed a commit that referenced this pull request Jun 23, 2016
@addaleax Myles Borins
stream: reset awaitDrain after manual .resume()
1ee0016
Reset the `readableState.awaitDrain` counter after manual calls to
`.resume()`.

What might happen otherwise is that a slow consumer at the end of the
pipe could end up stalling the piping in the following scenario:

1. The writable stream indicates that its buffer is full.
2. This leads the readable stream to `pause()` and increase its
   `awaitDrain` counter, which will be decreased by the writable’s next
   `drain` event.
3. Something calls `.resume()` manually.
4. The readable continues to pipe to the writable, but once again
   the writable stream indicates that the buffer is full.
5. The `awaitDrain` counter is thus increased again, but since it has
   now been increased twice for a single piping destination, the next
   `drain` event will not be able to reset `awaitDrain` to zero.
6. The pipe is stalled and no data is passed along anymore.

The solution in this commit is to reset the `awaitDrain` counter to
zero when `resume()` is called.

Fixes: #7159
PR-URL: #7160
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jun 24, 2016
v4.4.7 proposal #7395
Merged
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
@addaleax Myles Borins
stream: reset awaitDrain after manual .resume()
b73ec46
Reset the `readableState.awaitDrain` counter after manual calls to
`.resume()`.

What might happen otherwise is that a slow consumer at the end of the
pipe could end up stalling the piping in the following scenario:

1. The writable stream indicates that its buffer is full.
2. This leads the readable stream to `pause()` and increase its
   `awaitDrain` counter, which will be decreased by the writable’s next
   `drain` event.
3. Something calls `.resume()` manually.
4. The readable continues to pipe to the writable, but once again
   the writable stream indicates that the buffer is full.
5. The `awaitDrain` counter is thus increased again, but since it has
   now been increased twice for a single piping destination, the next
   `drain` event will not be able to reset `awaitDrain` to zero.
6. The pipe is stalled and no data is passed along anymore.

The solution in this commit is to reset the `awaitDrain` counter to
zero when `resume()` is called.

Fixes: #7159
PR-URL: #7160
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
@addaleax Myles Borins
stream: reset awaitDrain after manual .resume()
47efae6
Reset the `readableState.awaitDrain` counter after manual calls to
`.resume()`.

What might happen otherwise is that a slow consumer at the end of the
pipe could end up stalling the piping in the following scenario:

1. The writable stream indicates that its buffer is full.
2. This leads the readable stream to `pause()` and increase its
   `awaitDrain` counter, which will be decreased by the writable’s next
   `drain` event.
3. Something calls `.resume()` manually.
4. The readable continues to pipe to the writable, but once again
   the writable stream indicates that the buffer is full.
5. The `awaitDrain` counter is thus increased again, but since it has
   now been increased twice for a single piping destination, the next
   `drain` event will not be able to reset `awaitDrain` to zero.
6. The pipe is stalled and no data is passed along anymore.

The solution in this commit is to reset the `awaitDrain` counter to
zero when `resume()` is called.

Fixes: #7159
PR-URL: #7160
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jun 28, 2016
Myles Borins
2016-06-28, Version 4.4.7 'Argon' (LTS)
0974fc6
This LTS release comes with 89 commits. This includes 46 commits that
are docs related, 11 commits that are test related, 8 commits that are
build related, and 4 commits that are benchmark related.

Notable Changes:

- debugger:
  - All properties of an array (aside from length) can now be printed
    in the repl (cjihrig)
    #6448
- npm:
  - Upgrade npm to 2.15.8 (Rebecca Turner)
    #7412
- stream:
  - Fix for a bug that became more prevalent with the stream changes
    that landed in v4.4.5. (Anna Henningsen)
    #7160
- V8:
  - Fix for a bug in crankshaft that was causing crashes on arm64
    (Myles Borins)
    #7442
  - Add missing classes to postmortem info such as JSMap and JSSet
    (evan.lucas)
    #3792
MylesBorins pushed a commit that referenced this pull request Jun 28, 2016
Myles Borins
2016-06-28, Version 4.4.7 'Argon' (LTS)
21535e8
This LTS release comes with 89 commits. This includes 46 commits that
are docs related, 11 commits that are test related, 8 commits that are
build related, and 4 commits that are benchmark related.

Notable Changes:

- debugger:
  - All properties of an array (aside from length) can now be printed
    in the repl (cjihrig)
    #6448
- npm:
  - Upgrade npm to 2.15.8 (Rebecca Turner)
    #7412
- stream:
  - Fix for a bug that became more prevalent with the stream changes
    that landed in v4.4.5. (Anna Henningsen)
    #7160
- V8:
  - Fix for a bug in crankshaft that was causing crashes on arm64
    (Myles Borins)
    #7442
  - Add missing classes to postmortem info such as JSMap and JSSet
    (evan.lucas)
    #3792
@MylesBorins MylesBorins removed their assignment Dec 27, 2016
johnaAr555
johnaAr555 reviewed Apr 17, 2025
View reviewed changes

@johnaAr555 johnaAr555 left a comment

Copy link
Copy Markdown

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.

var state = this._readableState;
if (!state.flowing) {
debug('resume');

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
johnaAr555
johnaAr555 reviewed Apr 17, 2025
View reviewed changes

@johnaAr555 johnaAr555 left a comment

Copy link
Copy Markdown

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.

var state = this._readableState;
if (!state.flowing) {
debug('resume');

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@johnaAr555 johnaAr555 johnaAr555 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

stream Issues and PRs related to Node.js streams.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@addaleax @mcollina @jasnell @calvinmetcalf @MylesBorins @mafintosh @johnaAr555
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.