From 0ea079be7bb4fbe365626c3d194e71b512e672ab Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Tue, 7 Jul 2026 13:53:27 +0200 Subject: [PATCH] test: remove impact of tier-up changes in worker stack size test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The depth of the stack depends not only on the stack size, but also on the size of each stack frame, which in turn depends on which tier the recursive function happens to be running at when the overflow occurs. Under load the background tier-up can land at a non-deterministic point in the recursion and flake the test. Keep the recursive function in the interpreter with %NeverOptimizeFunction() so the frame size - and thus the depth - is deterministic. Signed-off-by: Joyee Cheung PR-URL: https://github.com/nodejs/node/pull/64271 Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- test/parallel/test-worker-stack-overflow-stack-size.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/parallel/test-worker-stack-overflow-stack-size.js b/test/parallel/test-worker-stack-overflow-stack-size.js index 481ff55100a..8aef401ab68 100644 --- a/test/parallel/test-worker-stack-overflow-stack-size.js +++ b/test/parallel/test-worker-stack-overflow-stack-size.js @@ -8,6 +8,14 @@ const { Worker } = require('worker_threads'); // Verify that Workers don't care about --stack-size, as they have their own // fixed and known stack sizes. +// The depth of the stack depends not only on the stack size, but also on the size of each +// stack frame, which in turn depends on which tier the recursive function happens to be +// running at when the overflow occurs. Under load the background tier-up can land at a +// non-deterministic point in the recursion and flake the test. Keep the recursive +// function in the interpreter with %NeverOptimizeFunction() so the frame size - +// and thus the depth - is deterministic. +v8.setFlagsFromString('--allow-natives-syntax'); + async function runWorker(options = {}) { const empiricalStackDepth = new Uint32Array(new SharedArrayBuffer(4)); const worker = new Worker(` @@ -16,6 +24,7 @@ async function runWorker(options = {}) { empiricalStackDepth[0]++; f(); } + %NeverOptimizeFunction(f); f();`, { eval: true, workerData: { empiricalStackDepth },