Skip to content
Permalink
Browse files

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>
  • Loading branch information
puzpuzpuz authored and MylesBorins committed Feb 26, 2020
1 parent 3c8daa3 commit 1539928ed915f54f5c2c1a1cafdb29d3b898f897
Showing with 20 additions and 0 deletions.
  1. +20 −0 test/async-hooks/test-async-local-storage-gcable.js
@@ -0,0 +1,20 @@
'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.runSyncAndReturn({}, () => {
asyncLocalStorage.disable();

onGC(asyncLocalStorage, { ongc: common.mustCall() });
});

asyncLocalStorage = null;
global.gc();

0 comments on commit 1539928

Please sign in to comment.
You can’t perform that action at this time.