mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
a9401439c7
- Ensure automatic destruction only happens after both 'end' and 'finish' has been emitted through autoDestroy. - Ensure close() callback is always invoked. - Ensure 'error' is only emitted once. PR-URL: https://github.com/nodejs/node/pull/32220 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
32 lines
634 B
JavaScript
32 lines
634 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
const zlib = require('zlib');
|
|
|
|
// Verify that the zlib transform does clean up
|
|
// the handle when calling destroy.
|
|
|
|
{
|
|
const ts = zlib.createGzip();
|
|
ts.destroy();
|
|
assert.strictEqual(ts._handle, null);
|
|
|
|
ts.on('close', common.mustCall(() => {
|
|
ts.close(common.mustCall());
|
|
}));
|
|
}
|
|
|
|
{
|
|
// Ensure 'error' is only emitted once.
|
|
const decompress = zlib.createGunzip(15);
|
|
|
|
decompress.on('error', common.mustCall((err) => {
|
|
decompress.close();
|
|
}));
|
|
|
|
decompress.write('something invalid');
|
|
decompress.destroy(new Error('asd'));
|
|
}
|