-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
stream: writableNeedDrain #35348
stream: writableNeedDrain #35348
Conversation
Review requested:
|
Needs tests. |
8d1c665
to
deabf75
Compare
deabf75
to
3976f6a
Compare
Don't write to a stream which already has a full buffer. Fixes: nodejs#35341
3976f6a
to
591616f
Compare
Fixes: #441 Refs: nodejs/node#35348 Refs: nodejs/node#35341
Fixes: #441 Refs: nodejs/node#35348 Refs: nodejs/node#35341
Fixes: #441 Refs: nodejs/node#35348 Refs: nodejs/node#35341
Fixes: #441 Refs: nodejs/node#35348 Refs: nodejs/node#35341
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
386afdf
to
0811886
Compare
@nodejs/streams |
if (dest.writableNeedDrain === true) { | ||
if (state.flowing) { | ||
src.pause(); | ||
} |
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'm a little unsure how this affects the case where src is already piped to other destinations?
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.
🤔 what about adding the stream to the state.awaitDrainWriters
(refs pipeOnDrain
+ ondata(chunk)
). Though that may require copying https://github.com/nodejs/node/pull/35348/files#diff-0117344ddd481d021ad96b9c8eea78a5R741-R747 from ondata
...
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 have no idea how that works or what it is intended for.
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.
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.
Any chance this can be reverted or done some other way? It seems to cause issues with the source getting stuck in a paused state if you previously fed the output buffer with a lot of data, see eg, electron/asar#210 That module basically just appends a bunch of files to a single binary, but after a random amount of files it gets stuck due to the source being in a paused state.
This could, of course, be easily worked around by adding the writableNeedDrain loop as in the issue above, or adding a resume call to the stream, but I feel like that shouldn't really be necessary.
@@ -801,7 +801,12 @@ Readable.prototype.pipe = function(dest, pipeOpts) { | |||
dest.emit('pipe', src); | |||
|
|||
// Start the flow if it hasn't been started already. | |||
if (!state.flowing) { | |||
|
|||
if (dest.writableNeedDrain === true) { |
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.
Nit: why not:
if (dest.writableNeedDrain === true) { | |
if (dest.writableNeedDrain) { |
if (dest.writableNeedDrain === true) { | ||
if (state.flowing) { | ||
src.pause(); | ||
} |
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.
🤔 what about adding the stream to the state.awaitDrainWriters
(refs pipeOnDrain
+ ondata(chunk)
). Though that may require copying https://github.com/nodejs/node/pull/35348/files#diff-0117344ddd481d021ad96b9c8eea78a5R741-R747 from ondata
...
Fixes: #441 Refs: nodejs/node#35348 Refs: nodejs/node#35341
@ronag is this ready to land? |
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
Landed in dd0f8f1 |
Fixes: #441 Refs: nodejs/node#35348 Refs: nodejs/node#35341
Fixes: #441 Refs: nodejs/node#35348 Refs: nodejs/node#35341
Fixes: #441 Refs: nodejs/node#35348 Refs: nodejs/node#35341
Adding don't land labels until #36544 is resolved. |
This requires bug fix in #36563 |
Don't write to a stream which already has a full buffer.
Fixes: #35341
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes