mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com> PR-URL: https://github.com/nodejs/node/pull/58535 Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
31 lines
735 B
JavaScript
31 lines
735 B
JavaScript
// Flags: --expose-gc --expose-internals
|
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { onGC } = require('../common/gc');
|
|
const assert = require('node:assert');
|
|
const { AsyncLocalStorage } = require('node:async_hooks');
|
|
const { freeParser, parsers, HTTPParser } = require('internal/http/common');
|
|
|
|
let storeGCed = false;
|
|
|
|
const als = new AsyncLocalStorage();
|
|
|
|
function test() {
|
|
const store = {};
|
|
onGC(store, { ongc: common.mustCall(() => { storeGCed = true; }) });
|
|
let parser;
|
|
als.run(store, common.mustCall(() => {
|
|
parser = parsers.alloc();
|
|
parser.initialize(HTTPParser.RESPONSE, {});
|
|
}));
|
|
freeParser(parser);
|
|
}
|
|
|
|
test();
|
|
global.gc();
|
|
setImmediate(common.mustCall(() => {
|
|
assert.ok(storeGCed);
|
|
}));
|