From cacefac677b5b39f40d9c9ce0010b56312f9b947 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 31 Jul 2026 17:18:53 -0700 Subject: [PATCH] test: use libuv clock for immediate queue test Use getLibuvNow() when waiting for the timeout to expire. Date.now() may have different precision from libuv's clock, causing the immediate queue to run an extra iteration on platforms with coarse timers. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: codex:gpt-5.6-sol --- test/parallel/test-timers-immediate-queue.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-timers-immediate-queue.js b/test/parallel/test-timers-immediate-queue.js index 8b433ddedbf4..517bb280d49d 100644 --- a/test/parallel/test-timers-immediate-queue.js +++ b/test/parallel/test-timers-immediate-queue.js @@ -19,9 +19,13 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +// Flags: --expose-internals --no-warnings + 'use strict'; require('../common'); const assert = require('assert'); +const { internalBinding } = require('internal/test/binding'); +const timersBinding = internalBinding('timers'); // setImmediate should run clear its queued cbs once per event loop turn // but immediates queued while processing the current queue should happen @@ -38,8 +42,8 @@ const QUEUE = 10; function run() { if (hit === 0) { setTimeout(() => { ticked = true; }, 1); - const now = Date.now(); - while (Date.now() - now < 2); + const now = timersBinding.getLibuvNow(); + while (timersBinding.getLibuvNow() - now < 2); } if (ticked) return;