-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add GC test for disabled AsyncLocalStorage
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |