-
-
Notifications
You must be signed in to change notification settings - Fork 32k
stream: writableNeedDrain #35348
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Nit: why not:
Suggested change
|
||||||
if (state.flowing) { | ||||||
src.pause(); | ||||||
} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 what about adding the stream to the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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. |
||||||
} else if (!state.flowing) { | ||||||
debug('pipe resume'); | ||||||
src.resume(); | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const Readable = require('_stream_readable'); | ||
const Writable = require('_stream_writable'); | ||
|
||
// Pipe should not continue writing if writable needs drain. | ||
{ | ||
const w = new Writable({ | ||
write(buf, encoding, callback) { | ||
|
||
} | ||
}); | ||
|
||
while (w.write('asd')); | ||
|
||
assert.strictEqual(w.writableNeedDrain, true); | ||
|
||
const r = new Readable({ | ||
read() { | ||
this.push('asd'); | ||
} | ||
}); | ||
|
||
w.write = common.mustNotCall(); | ||
|
||
r.pipe(w); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.