Skip to content

Commit

Permalink
test: fix test-http-server-keepalive-req-gc
Browse files Browse the repository at this point in the history
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: #53292
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Etienne Pierre-doray authored and marco-ippolito committed Jul 19, 2024
1 parent 50235e8 commit ca3220f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/parallel/test-http-server-keepalive-req-gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit ca3220f

Please sign in to comment.