stream: prevent stream unexpected pause when highWaterMark set to 0
Co-authored-by: Robert Nagy <ronagy@icloud.com> PR-URL: https://github.com/nodejs/node/pull/53261 Fixes: https://github.com/nodejs/node/issues/51930 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
5a446ccf37
commit
50695e5de1
@ -565,7 +565,7 @@ function writeOrBuffer(stream, state, chunk, encoding, callback) {
|
|||||||
state[kState] &= ~kSync;
|
state[kState] &= ~kSync;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ret = state.length < state.highWaterMark;
|
const ret = state.length < state.highWaterMark || state.length === 0;
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
state[kState] |= kNeedDrain;
|
state[kState] |= kNeedDrain;
|
||||||
|
@ -85,3 +85,27 @@ const { inspect } = require('util');
|
|||||||
hwm,
|
hwm,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const res = [];
|
||||||
|
const r = new stream.Readable({
|
||||||
|
read() {},
|
||||||
|
});
|
||||||
|
const w = new stream.Writable({
|
||||||
|
highWaterMark: 0,
|
||||||
|
write(chunk, encoding, callback) {
|
||||||
|
res.push(chunk.toString());
|
||||||
|
callback();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
r.pipe(w);
|
||||||
|
r.push('a');
|
||||||
|
r.push('b');
|
||||||
|
r.push('c');
|
||||||
|
r.push(null);
|
||||||
|
|
||||||
|
r.on('end', common.mustCall(() => {
|
||||||
|
assert.deepStrictEqual(res, ['a', 'b', 'c']);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user