Skip to content

Commit e4f1c18

Browse files
committed
test: add GC test for disabled AsyncLocalStorage
1 parent 6bcea0a commit e4f1c18

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
// Flags: --expose_gc
3+
4+
// This test ensures that AsyncLocalStorage gets gced once it was disabled
5+
// and no strong references remain in userland.
6+
7+
const common = require('../common');
8+
const { AsyncLocalStorage } = require('async_hooks');
9+
const onGC = require('../common/ongc');
10+
11+
let asyncLocalStorage = new AsyncLocalStorage();
12+
13+
asyncLocalStorage.runSyncAndReturn({}, () => {
14+
asyncLocalStorage.disable();
15+
16+
onGC(asyncLocalStorage, { ongc: common.mustCall() });
17+
});
18+
19+
asyncLocalStorage = null;
20+
global.gc();

0 commit comments

Comments
 (0)