mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 03:45:25 +00:00

PR-URL: https://github.com/nodejs/node/pull/56712 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
22 lines
523 B
JavaScript
22 lines
523 B
JavaScript
'use strict';
|
|
// Flags: --expose_gc
|
|
|
|
// This test ensures that userland-only AsyncResources cause a destroy event to
|
|
// be emitted when they get gced.
|
|
|
|
const common = require('../common');
|
|
const async_hooks = require('async_hooks');
|
|
|
|
const hook = async_hooks.createHook({
|
|
destroy: common.mustCallAtLeast(1) // only 1 immediate is destroyed
|
|
}).enable();
|
|
|
|
new async_hooks.AsyncResource('foobar', { requireManualDestroy: true });
|
|
|
|
setImmediate(() => {
|
|
globalThis.gc();
|
|
setImmediate(() => {
|
|
hook.disable();
|
|
});
|
|
});
|