Commit 768315cf716 for nodejs
commit 768315cf7165e9ff9b636844b776488e9d1703fc
Author: Matteo Collina <hello@matteocollina.com>
Date: Sun Nov 8 21:34:22 2026 +0100
test: deflake test-worker-eventlooputil
worker.performance.eventLoopUtilization() reads the worker's idle time
before the current time. If the parent thread stalls between the two
reads while the worker is idle, the stall is counted as worker active
time in the first sample and is missing from the delta, so the 50ms
spin can be reported as slightly less than 50ms.
Bound that skew by timing the first workerELU() call.
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67260
Refs: https://github.com/nodejs/reliability/issues/1482
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
diff --git a/test/sequential/test-worker-eventlooputil.js b/test/sequential/test-worker-eventlooputil.js
index 39c6d723ff7..8c8a0e3d4b6 100644
--- a/test/sequential/test-worker-eventlooputil.js
+++ b/test/sequential/test-worker-eventlooputil.js
@@ -95,13 +95,19 @@ function checkWorkerIdle(wElu) {
}
function checkWorkerActive() {
+ // Reading the worker's ELU from this thread is not atomic: the worker's idle
+ // time is read before the current time. If this thread stalls between the
+ // two reads while the worker is idle, the stall is counted as worker active
+ // time in `w` and then missing from `w2`. The duration of the call bounds it.
+ const start = performance.now();
const w = workerELU();
+ const skew = performance.now() - start;
metricsCh.port2.postMessage({ cmd: 'spin', dur: 50 });
metricsCh.port2.once('message', mustCall((wElu) => {
const w2 = workerELU(w);
- assert.ok(w2.active >= 50, `${w2.active} < 50`);
+ assert.ok(w2.active >= 50 - skew, `${w2.active} < 50 - ${skew}`);
assert.ok(wElu.active >= 50, `${wElu.active} < 50`);
assert.ok(idleActive(wElu) < idleActive(w2),
`${idleActive(wElu)} >= ${idleActive(w2)}`);