Skip to content

Commit 1539928

Browse files
puzpuzpuzMylesBorins
authored andcommittedMar 4, 2020
test: add GC test for disabled AsyncLocalStorage
PR-URL: #31995 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 3c8daa3 commit 1539928

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)
Please sign in to comment.