mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
0b6b2a4dc7
PR-URL: https://github.com/nodejs/node/pull/54355 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
29 lines
793 B
JavaScript
29 lines
793 B
JavaScript
// Flags: --expose-gc
|
|
'use strict';
|
|
const common = require('../common');
|
|
const { onGC } = require('../common/gc');
|
|
const assert = require('assert');
|
|
const zlib = require('zlib');
|
|
|
|
// Checks that, if a zlib context fails with an error, it can still be GC'ed:
|
|
// Refs: https://github.com/nodejs/node/issues/22705
|
|
|
|
const ongc = common.mustCall();
|
|
|
|
{
|
|
const input = Buffer.from('foobar');
|
|
const strm = zlib.createInflate();
|
|
strm.end(input);
|
|
strm.once('error', common.mustCall((err) => {
|
|
assert(err);
|
|
setImmediate(() => {
|
|
global.gc();
|
|
// Keep the event loop alive for seeing the async_hooks destroy hook
|
|
// we use for GC tracking...
|
|
// TODO(addaleax): This should maybe not be necessary?
|
|
setImmediate(() => {});
|
|
});
|
|
}));
|
|
onGC(strm, { ongc });
|
|
}
|