node/test/parallel/test-zlib-flush-drain-longblock.js
Anna Henningsen 717a138b4a
zlib: fix interaction of flushing and needDrain
Fixes: https://github.com/nodejs/node/issues/14523
PR-URL: https://github.com/nodejs/node/pull/14527
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-07-31 22:44:05 +02:00

28 lines
726 B
JavaScript

'use strict';
// Regression test for https://github.com/nodejs/node/issues/14523.
// Checks that flushes interact properly with writableState.needDrain,
// even if no flush callback was passed.
const common = require('../common');
const assert = require('assert');
const zlib = require('zlib');
const zipper = zlib.createGzip({ highWaterMark: 16384 });
const unzipper = zlib.createGunzip();
zipper.pipe(unzipper);
zipper.write('A'.repeat(17000));
zipper.flush();
let received = 0;
unzipper.on('data', common.mustCall((d) => {
received += d.length;
}, 2));
// Properly `.end()`ing the streams would interfere with checking that
// `.flush()` works.
process.on('exit', () => {
assert.strictEqual(received, 17000);
});