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: only increase awaitDrain once for each pipe destination by davedoesdev · Pull Request #7292 · nodejs/node

Conversation

@davedoesdev

@davedoesdev davedoesdev commented Jun 13, 2016 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor
Checklist
  • make -j4 test (UNIX) or vcbuild test nosign (Windows) passes
  • a test and/or benchmark is included
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)

stream

Description of change

Guard against the call to write() inside pipe's ondata pushing more data
back onto the Readable, thus causing ondata to be called again.

This is fine but results in awaitDrain being increased more than once.
The problem with that is when the destination does drain, only a single drain
event is emitted, so awaitDrain in this case will never reach zero and we
end up with a permanently paused stream.
#7278

Sorry, something went wrong.

Uh oh!

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

All reactions
@nodejs-github-bot nodejs-github-bot added the stream Issues and PRs related to Node.js streams. label Jun 13, 2016
addaleax
addaleax reviewed Jun 13, 2016
View reviewed changes
Comment thread test/parallel/test-stream-pipe-await-drain-push-while-write.js Outdated

@addaleax addaleax Jun 13, 2016

Copy link
Copy Markdown
Member

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.

Just curious, would a Readable suffice here?

Sorry, something went wrong.

Uh oh!

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

All reactions

@davedoesdev davedoesdev Jun 13, 2016

Copy link
Copy Markdown
Contributor Author

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.

Yes, but I'd have to set its _read to a nullop.

Sorry, something went wrong.

Uh oh!

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

All reactions

@davedoesdev davedoesdev Jun 13, 2016

Copy link
Copy Markdown
Contributor Author

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 guess I could try doing the pushs in the _read.

Sorry, something went wrong.

Uh oh!

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

All reactions

@addaleax addaleax Jun 13, 2016

Copy link
Copy Markdown
Member

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.

You could use new stream.Readable({read: () => {}}), but you can just leave it as a PassThrough if you prefer, I really was just curious. :)

Sorry, something went wrong.

Uh oh!

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

All reactions
@addaleax

addaleax commented Jun 13, 2016

Copy link
Copy Markdown
Member

Thanks, generally looking good! If you want, you can add an Fixes: https://github.com/nodejs/node/issues/7278 line to the commit message so the issue will automatically be closed when this is landed.

All reactions

Sorry, something went wrong.

Uh oh!

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

@davedoesdev

davedoesdev commented Jun 13, 2016

Copy link
Copy Markdown
Contributor Author

@addaleax thanks for the review. I'll add a commit addressing your comments but it won't be today now.

All reactions

Sorry, something went wrong.

Uh oh!

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

@davedoesdev

davedoesdev commented Jun 13, 2016

Copy link
Copy Markdown
Contributor Author

okay I just updated the test

All reactions

Sorry, something went wrong.

Uh oh!

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

This was referenced Jun 13, 2016
Change in stream behaviour in Node 4.4.5 #7278
Closed
Streams Regression in v4.x nodejs/Release#112
Closed
addaleax
addaleax reviewed Jun 14, 2016
View reviewed changes
Comment thread test/parallel/test-stream-pipe-await-drain-push-while-write.js Outdated

@addaleax addaleax Jun 14, 2016

Copy link
Copy Markdown
Member

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.

Is this line actually necessary? I think the test still tests what it’s supposed to test if you leave it out, because after the push() call here awaitDrain would already be 2… right?

Sorry, something went wrong.

Uh oh!

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

All reactions

@davedoesdev davedoesdev Jun 14, 2016

Copy link
Copy Markdown
Contributor Author

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 wanted to test the effect (missing third buffer) rather than the cause.
In any case, awaitDrain isn't incremented until _write returns so it won't already be 2.

Sorry, something went wrong.

Uh oh!

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

All reactions
@addaleax

addaleax commented Jun 14, 2016

Copy link
Copy Markdown
Member

/cc @nodejs/streams

I’d be kind of interested in knowing whether we generally guarantee that .push() and/or .write() are reentrant and can be called recursively or not.

All reactions

Sorry, something went wrong.

Uh oh!

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

@addaleax

addaleax commented Jun 14, 2016

Copy link
Copy Markdown
Member

Also, I’m not sure why, but this branch seems to be based on a master that’s about a month old – rebasing might be nice for testing this out locally.

All reactions

Sorry, something went wrong.

Uh oh!

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

@davedoesdev

davedoesdev commented Jun 14, 2016

Copy link
Copy Markdown
Contributor Author

If push and write aren't reentrant then it'd be great to add it to the API docs.

All reactions

Sorry, something went wrong.

Uh oh!

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

@davedoesdev

davedoesdev commented Jun 14, 2016

Copy link
Copy Markdown
Contributor Author

No idea why it's a month old - only forked it yesterday.

All reactions

Sorry, something went wrong.

Uh oh!

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

@davedoesdev

davedoesdev commented Jun 14, 2016 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

This branch is now rebased on latest master.

All reactions

Sorry, something went wrong.

Uh oh!

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

@davedoesdev

davedoesdev commented Jun 14, 2016

Copy link
Copy Markdown
Contributor Author

@addaleax I removed the process.nextTick since resume/flow takes care of that now in the test. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

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

mcollina
mcollina reviewed Jun 14, 2016
View reviewed changes
Comment thread lib/_stream_readable.js Outdated

@mcollina mcollina Jun 14, 2016

Copy link
Copy Markdown
Member

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.

can you please add a comment on the reason for this variable?

Sorry, something went wrong.

Uh oh!

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

All reactions

@mafintosh mafintosh Jun 14, 2016

Copy link
Copy Markdown
Member

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.

also we probably wanna move up the declaration of increasedAwaitDrain to before the ondata handler is attached. i'm pretty sure that might fire sync in some cases

Sorry, something went wrong.

Uh oh!

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

All reactions
@mcollina mcollina added the good first issue Issues that are suitable for first-time contributors. label Jun 14, 2016
@mcollina

mcollina commented Jun 14, 2016

Copy link
Copy Markdown
Member

Can you please format the commit message and squash the commits?

All reactions

Sorry, something went wrong.

Uh oh!

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

@mcollina

mcollina commented Jun 14, 2016

Copy link
Copy Markdown
Member

This bug is "fixed" from [email protected] to [email protected], where 2.0.3 and 2.1.3 are broken.

cc @calvinmetcalf

All reactions

Sorry, something went wrong.

Uh oh!

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

@davedoesdev
stream: ensure awaitDrain is increased once
02cbb90
Guard against the call to write() inside pipe's ondata pushing more data
back onto the Readable, thus causing ondata to be called again.

This is fine but results in awaitDrain being increased more than once.
The problem with that is when the destination does drain, only a single
'drain' event is emitted, so awaitDrain in this case will never reach
zero and we end up with a permanently paused stream.
@addaleax addaleax removed the good first issue Issues that are suitable for first-time contributors. label Jun 14, 2016
@addaleax

addaleax commented Jun 14, 2016 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

@mcollina I assume the “fixed” range corresponds to #2325 … #6023?

And I’m not sure why you added good first contribution to a PR… I mean, it is a good first contribution, but I think that’s rather used to signal that an issue is up for grabs by newbies? I’m removing it but feel free to re-add.

All reactions

Sorry, something went wrong.

Uh oh!

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

@mcollina

mcollina commented Jun 14, 2016

Copy link
Copy Markdown
Member

@addaleax exactly. That means if you are depending on readable-stream@~2.0 it's fixed, and broken in readable-stream@~2.1 and readable-stream@^2.1.

(I thought good first contribution was to tag possible future contributors, maybe I got it wrong)

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

@davedoesdev

davedoesdev commented Jun 15, 2016

Copy link
Copy Markdown
Contributor Author

Should be squashed and reformatted now.

All reactions

Sorry, something went wrong.

Uh oh!

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

@mcollina

mcollina commented Jun 15, 2016

Copy link
Copy Markdown
Member

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

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

@addaleax

addaleax commented Jun 15, 2016

Copy link
Copy Markdown
Member

CI: https://ci.nodejs.org/job/node-test-commit/3753/
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/303/ (If I’ve got everything right)

All reactions

Sorry, something went wrong.

Uh oh!

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

@addaleax

addaleax commented Jun 15, 2016

Copy link
Copy Markdown
Member

LGTM

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 15, 2016
@addaleax addaleax assigned MylesBorins Jun 15, 2016
@addaleax

addaleax commented Jun 15, 2016

Copy link
Copy Markdown
Member

Landed in b5175e8

Thanks for fixing this bug, @davedoesdev! I believe this is your first commit to core, if so, welcome on board and we hope you find other ways to contribute!

All reactions

Sorry, something went wrong.

Uh oh!

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

@addaleax addaleax closed this Jun 15, 2016
addaleax pushed a commit that referenced this pull request Jun 15, 2016
@davedoesdev @addaleax
stream: ensure awaitDrain is increased once
b5175e8
Guard against the call to write() inside pipe's ondata pushing more data
back onto the Readable, thus causing ondata to be called again.

This is fine but results in awaitDrain being increased more than once.
The problem with that is when the destination does drain, only a single
'drain' event is emitted, so awaitDrain in this case will never reach
zero and we end up with a permanently paused stream.

Fixes: #7278
PR-URL: #7292
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
evanlucas pushed a commit that referenced this pull request Jun 16, 2016
@davedoesdev @evanlucas
stream: ensure awaitDrain is increased once
b0225e5
Guard against the call to write() inside pipe's ondata pushing more data
back onto the Readable, thus causing ondata to be called again.

This is fine but results in awaitDrain being increased more than once.
The problem with that is when the destination does drain, only a single
'drain' event is emitted, so awaitDrain in this case will never reach
zero and we end up with a permanently paused stream.

Fixes: #7278
PR-URL: #7292
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Fishrock123
Fishrock123 reviewed Jun 16, 2016
View reviewed changes
Comment thread test/parallel/test-stream-pipe-await-drain-push-while-write.js
// A readable stream which produces two buffers.
const bufs = [new Buffer(32 * 1024), new Buffer(33 * 1024)]; // above hwm
const readable = new stream.Readable({
read: function() {

@Fishrock123 Fishrock123 Jun 16, 2016

Copy link
Copy Markdown
Contributor

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.

could have been read() { ^_^

Sorry, something went wrong.

Uh oh!

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

All reactions
@evanlucas evanlucas mentioned this pull request Jun 16, 2016
v6.2.2 proposal #7323
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
@davedoesdev Myles Borins
stream: ensure awaitDrain is increased once
0dae3ca
Guard against the call to write() inside pipe's ondata pushing more data
back onto the Readable, thus causing ondata to be called again.

This is fine but results in awaitDrain being increased more than once.
The problem with that is when the destination does drain, only a single
'drain' event is emitted, so awaitDrain in this case will never reach
zero and we end up with a permanently paused stream.

Fixes: #7278
PR-URL: #7292
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[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
@davedoesdev Myles Borins
stream: ensure awaitDrain is increased once
a08a017
Guard against the call to write() inside pipe's ondata pushing more data
back onto the Readable, thus causing ondata to be called again.

This is fine but results in awaitDrain being increased more than once.
The problem with that is when the destination does drain, only a single
'drain' event is emitted, so awaitDrain in this case will never reach
zero and we end up with a permanently paused stream.

Fixes: #7278
PR-URL: #7292
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jun 24, 2016
@davedoesdev Myles Borins
stream: ensure awaitDrain is increased once
17a41c6
Guard against the call to write() inside pipe's ondata pushing more data
back onto the Readable, thus causing ondata to be called again.

This is fine but results in awaitDrain being increased more than once.
The problem with that is when the destination does drain, only a single
'drain' event is emitted, so awaitDrain in this case will never reach
zero and we end up with a permanently paused stream.

Fixes: #7278
PR-URL: #7292
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@MylesBorins MylesBorins removed their assignment Dec 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

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

@davedoesdev @addaleax @mcollina @mafintosh @Fishrock123 @MylesBorins @nodejs-github-bot
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.