-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: fix 0 transform hwm backpressure
PR-URL: #43685 Refs: #42457 Refs: https://github.com/nodejs/node/pull/43648/files Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
- Loading branch information
1 parent
7b276b8
commit bf3991b
Showing
4 changed files
with
54 additions
and
24 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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { PassThrough } = require('stream'); | ||
|
||
const pt = new PassThrough({ highWaterMark: 0 }); | ||
pt.on('drain', common.mustCall()); | ||
pt.write('hello'); | ||
assert(!pt.write('hello1')); | ||
pt.read(); | ||
pt.read(); |
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,28 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { Transform } = require('stream'); | ||
|
||
const t = new Transform({ | ||
objectMode: true, highWaterMark: 0, | ||
transform(chunk, enc, callback) { | ||
process.nextTick(() => callback(null, chunk, enc)); | ||
} | ||
}); | ||
|
||
assert.strictEqual(t.write(1), false); | ||
t.on('drain', common.mustCall(() => { | ||
assert.strictEqual(t.write(2), false); | ||
t.end(); | ||
})); | ||
|
||
t.once('readable', common.mustCall(() => { | ||
assert.strictEqual(t.read(), 1); | ||
setImmediate(common.mustCall(() => { | ||
assert.strictEqual(t.read(), null); | ||
t.once('readable', common.mustCall(() => { | ||
assert.strictEqual(t.read(), 2); | ||
})); | ||
})); | ||
})); |
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