test: fix test-http-server-keepalive-req-gc

This changes adds a second explicit gc call in the test. Without this
call, the test relies on gc eventually happening based, since the
first call doesn't free the object.
Relying on gc to eventually happen prevents changing GC heuristics
unrelated to this test.
The gc call is async; otherwise doing multiple sync GCs doesn't free
the object.

PR-URL: https://github.com/nodejs/node/pull/53292
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Etienne Pierre-doray authored and Marco Ippolito committed 2024-07-19 15:27:07 +02:00
1 parent d18a67f937
commit 49e6f33021
1 file changed
+3 -2
@@ -14,9 +14,10 @@ const server = createServer(common.mustCall((req, res) => {
onGC(req, { ongc: common.mustCall(() => { server.close(); }) });
req.resume();
req.on('end', common.mustCall(() => {
setImmediate(() => {
setImmediate(async () => {
client.end();
global.gc();
await global.gc({ type: 'major', execution: 'async' });
await global.gc({ type: 'major', execution: 'async' });
});
}));
res.end('hello world');