Files
node/test/parallel/test-async-local-storage-http-parser-leak.js
Sebastian Beltran 12ce81920a lib: deprecate _http_*
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>
2026-10-15 00:52:34 +00:00

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);
}));