From 115a03682cc47cc522f1eea8cc2bc11fac05e092 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Tue, 23 Jun 2026 20:15:59 -0700 Subject: [PATCH] test: limit young generation in heap snapshot tests Set maxYoungGenerationSizeMb for the worker heap snapshot tests so the temporary heap limit used while writing the snapshot is deterministic. This keeps the tests focused on verifying that one snapshot is written before the worker reports ERR_WORKER_OUT_OF_MEMORY. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: openai:gpt-5.5 --- .../workload/grow-worker-and-set-near-heap-limit.js | 7 +++++-- test/fixtures/workload/grow-worker.js | 7 +++++-- .../test-heapsnapshot-near-heap-limit-by-api-in-worker.js | 1 + test/parallel/test-heapsnapshot-near-heap-limit-worker.js | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/test/fixtures/workload/grow-worker-and-set-near-heap-limit.js b/test/fixtures/workload/grow-worker-and-set-near-heap-limit.js index 598088bcf90a78..b7a379e24b4d1c 100644 --- a/test/fixtures/workload/grow-worker-and-set-near-heap-limit.js +++ b/test/fixtures/workload/grow-worker-and-set-near-heap-limit.js @@ -9,7 +9,10 @@ new Worker(path.join(__dirname, 'grow-and-set-near-heap-limit.js'), { }, resourceLimits: { maxOldGenerationSizeMb: - parseInt(process.env.TEST_OLD_SPACE_SIZE) || 20 - } + parseInt(process.env.TEST_OLD_SPACE_SIZE) || 20, + ...(process.env.TEST_YOUNG_SPACE_SIZE !== undefined && { + maxYoungGenerationSizeMb: parseInt(process.env.TEST_YOUNG_SPACE_SIZE), + }), + }, }); diff --git a/test/fixtures/workload/grow-worker.js b/test/fixtures/workload/grow-worker.js index 092d8f27751fc2..c80a5cd7b91128 100644 --- a/test/fixtures/workload/grow-worker.js +++ b/test/fixtures/workload/grow-worker.js @@ -9,6 +9,9 @@ new Worker(path.join(__dirname, 'grow.js'), { ], resourceLimits: { maxOldGenerationSizeMb: - parseInt(process.env.TEST_OLD_SPACE_SIZE) || 20 - } + parseInt(process.env.TEST_OLD_SPACE_SIZE) || 20, + ...(process.env.TEST_YOUNG_SPACE_SIZE !== undefined && { + maxYoungGenerationSizeMb: parseInt(process.env.TEST_YOUNG_SPACE_SIZE), + }), + }, }); diff --git a/test/parallel/test-heapsnapshot-near-heap-limit-by-api-in-worker.js b/test/parallel/test-heapsnapshot-near-heap-limit-by-api-in-worker.js index ac55933a47122b..b7f4946c060cff 100644 --- a/test/parallel/test-heapsnapshot-near-heap-limit-by-api-in-worker.js +++ b/test/parallel/test-heapsnapshot-near-heap-limit-by-api-in-worker.js @@ -22,6 +22,7 @@ const env = { env: { TEST_SNAPSHOTS: 1, TEST_OLD_SPACE_SIZE: 50, + TEST_YOUNG_SPACE_SIZE: 16, ...env } }); diff --git a/test/parallel/test-heapsnapshot-near-heap-limit-worker.js b/test/parallel/test-heapsnapshot-near-heap-limit-worker.js index 46744cbd44d82c..2701499c53bfbd 100644 --- a/test/parallel/test-heapsnapshot-near-heap-limit-worker.js +++ b/test/parallel/test-heapsnapshot-near-heap-limit-worker.js @@ -20,6 +20,7 @@ const env = { env: { TEST_SNAPSHOTS: 1, TEST_OLD_SPACE_SIZE: 50, + TEST_YOUNG_SPACE_SIZE: 16, ...env } });