diff options
author | Robert Nagy <ronagy@icloud.com> | 2019-08-12 14:39:18 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-08-16 16:01:43 -0700 |
commit | 7195cd6fb30519271b09b437d0045d9cc8418a37 (patch) | |
tree | cc52c85af3bb2fb05b68824f0c6db8e003f1400a /test/parallel/test-stream-pipe-flow.js | |
parent | 4111c57f7ca3fd2993b60e86bea2abe63d124c65 (diff) | |
download | android-node-v8-7195cd6fb30519271b09b437d0045d9cc8418a37.tar.gz android-node-v8-7195cd6fb30519271b09b437d0045d9cc8418a37.tar.bz2 android-node-v8-7195cd6fb30519271b09b437d0045d9cc8418a37.zip |
stream: use lazy registration for drain for fast destinations
PR-URL: https://github.com/nodejs/node/pull/29095
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test/parallel/test-stream-pipe-flow.js')
-rw-r--r-- | test/parallel/test-stream-pipe-flow.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/parallel/test-stream-pipe-flow.js b/test/parallel/test-stream-pipe-flow.js index b696821c0d..1f2e8f54ce 100644 --- a/test/parallel/test-stream-pipe-flow.js +++ b/test/parallel/test-stream-pipe-flow.js @@ -1,5 +1,6 @@ 'use strict'; const common = require('../common'); +const assert = require('assert'); const { Readable, Writable, PassThrough } = require('stream'); { @@ -65,3 +66,25 @@ const { Readable, Writable, PassThrough } = require('stream'); wrapper.resume(); wrapper.on('end', common.mustCall()); } + +{ + // Only register drain if there is backpressure. + const rs = new Readable({ read() {} }); + + const pt = rs + .pipe(new PassThrough({ objectMode: true, highWaterMark: 2 })); + assert.strictEqual(pt.listenerCount('drain'), 0); + pt.on('finish', () => { + assert.strictEqual(pt.listenerCount('drain'), 0); + }); + + rs.push('asd'); + assert.strictEqual(pt.listenerCount('drain'), 0); + + process.nextTick(() => { + rs.push('asd'); + assert.strictEqual(pt.listenerCount('drain'), 0); + rs.push(null); + assert.strictEqual(pt.listenerCount('drain'), 0); + }); +} |