mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
Decide the return status of writeOrBuffer before calling stream.write which can reset state.length Add unit test for #35926 Refs: https://github.com/nodejs/node/issues/35926 PR-URL: https://github.com/nodejs/node/pull/35941 Fixes: https://github.com/nodejs/node/issues/35926 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
33 lines
563 B
JavaScript
33 lines
563 B
JavaScript
'use strict';
|
|
// https://github.com/nodejs/node/issues/35926
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const stream = require('stream');
|
|
|
|
let loops = 5;
|
|
|
|
const src = new stream.Readable({
|
|
read() {
|
|
if (loops--)
|
|
this.push(Buffer.alloc(20000));
|
|
}
|
|
});
|
|
|
|
const dst = new stream.Transform({
|
|
transform(chunk, output, fn) {
|
|
this.push(null);
|
|
fn();
|
|
}
|
|
});
|
|
|
|
src.pipe(dst);
|
|
|
|
function parser_end() {
|
|
assert.ok(loops > 0);
|
|
dst.removeAllListeners();
|
|
}
|
|
|
|
dst.on('data', () => { });
|
|
dst.on('end', parser_end);
|
|
dst.on('error', parser_end);
|