1'use strict'; 2// Flags: --expose_gc 3 4// This test ensures that userland-only AsyncResources cause a destroy event to 5// be emitted when they get gced. 6 7const common = require('../common'); 8const async_hooks = require('async_hooks'); 9 10const hook = async_hooks.createHook({ 11 destroy: common.mustCallAtLeast(2) // 1 immediate + manual destroy 12}).enable(); 13 14{ 15 const res = new async_hooks.AsyncResource('foobar'); 16 res.emitDestroy(); 17} 18 19setImmediate(() => { 20 global.gc(); 21 setImmediate(() => { 22 hook.disable(); 23 }); 24}); 25