-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: fix regression on duplex end
Decide the return status of writeOrBuffer before calling stream.write which can reset state.length Add unit test for #35926 Refs: #35926 Backport-PR-URL: #36375 PR-URL: #35941 Fixes: #35926 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
- Loading branch information
1 parent
cd1c629
commit 5904671
Showing
2 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'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); |