mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 22:16:31 +00:00

This is purely cleanup and carries no visible behavioural changes. Up to now, `this._closed` was used in zlib.js as a synonym of `!this._handle`. This change makes this connection explicit and removes the `_closed` property from zlib streams, as the previous duplication has been the cause of subtle errors like https://github.com/nodejs/node/issues/6034. This also makes zlib errors lead to an explicit `_close()` call rather than waiting for garbage collection to clean up the handle, thus returning memory resources earlier in the case of an error. Add a getter for `_closed` so that the property remains accessible by legacy code. PR-URL: https://github.com/nodejs/node/pull/6574 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
17 lines
445 B
JavaScript
17 lines
445 B
JavaScript
'use strict';
|
|
// https://github.com/nodejs/node/issues/6034
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const zlib = require('zlib');
|
|
|
|
const decompress = zlib.createGunzip(15);
|
|
|
|
decompress.on('error', common.mustCall((err) => {
|
|
assert.strictEqual(decompress._closed, true);
|
|
assert.doesNotThrow(() => decompress.close());
|
|
}));
|
|
|
|
assert.strictEqual(decompress._closed, false);
|
|
decompress.write('something invalid');
|