forked from mmomtchev/node
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Backport Decide the return status of writeOrBuffer before calling stream.write which can reset state.length Refs: nodejs#35941 Fixes: nodejs#35926
- Loading branch information
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); |