node/test/async-hooks/test-async-local-storage-gcable.js
Andrey Pechkurov 50dd63e8ef
async_hooks: merge run and exit methods
PR-URL: https://github.com/nodejs/node/pull/31950
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2020-04-13 18:37:44 +02:00

21 lines
509 B
JavaScript

'use strict';
// Flags: --expose_gc
// This test ensures that AsyncLocalStorage gets gced once it was disabled
// and no strong references remain in userland.
const common = require('../common');
const { AsyncLocalStorage } = require('async_hooks');
const onGC = require('../common/ongc');
let asyncLocalStorage = new AsyncLocalStorage();
asyncLocalStorage.run({}, () => {
asyncLocalStorage.disable();
onGC(asyncLocalStorage, { ongc: common.mustCall() });
});
asyncLocalStorage = null;
global.gc();