Skip to content

Commit

Permalink
test: add GC test for disabled AsyncLocalStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
puzpuzpuz committed Mar 2, 2020
1 parent 6bcea0a commit e4f1c18
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions 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 e4f1c18

Please sign in to comment.