From ca3220ffaf0d24661c37791fd91c9d8735a3cf72 Mon Sep 17 00:00:00 2001 From: Etienne Pierre-doray Date: Tue, 28 May 2024 21:47:19 +0000 Subject: [PATCH] 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 --- test/parallel/test-http-server-keepalive-req-gc.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http-server-keepalive-req-gc.js b/test/parallel/test-http-server-keepalive-req-gc.js index 0c68ebab763223..93310847d670a7 100644 --- a/test/parallel/test-http-server-keepalive-req-gc.js +++ b/test/parallel/test-http-server-keepalive-req-gc.js @@ -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');