From 31b1f27a2e2e80675c0fd3360191a9c8f1314176 Mon Sep 17 00:00:00 2001 From: German Khokhlov Date: Tue, 3 Nov 2026 19:55:33 +0400 Subject: [PATCH] Wait for the traffic refinement task by task instead of for five milliseconds The handoff test failed under a loaded test runner when the refined pass needed more yields than a fixed 5 ms timer allowed; it now yields until the refined paint lands (bounded by a task count, not wall time). --- src/layers/traffic/handoff.test.mjs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/layers/traffic/handoff.test.mjs b/src/layers/traffic/handoff.test.mjs index a5a5a4960..5e5f84e53 100644 --- a/src/layers/traffic/handoff.test.mjs +++ b/src/layers/traffic/handoff.test.mjs @@ -6,6 +6,7 @@ import { createState } from './state.js'; import { createFlow } from './flow.js'; import { createLifecycle } from './lifecycle.js'; import { DOT_HEIGHT_OFFSET } from './policy.js'; +import { nextTask } from '../../sources/vectorTiles.js'; const LON = -97.744; const LAT = 30.267; @@ -105,7 +106,12 @@ function fixture(surface) { } const height = (point) => C.Cartographic.fromCartesian(point).height; -const settle = () => new Promise((resolve) => setTimeout(resolve, 5)); +// The refinement runs in tasks the flow yields between (nextTask). Wait for +// its outcome task by task instead of for a fixed time, which a loaded test +// runner can outlast. +const settle = async (done) => { + for (let task = 0; task < 500 && !done(); task++) await nextTask(); +}; test('a republish weights roads by distance to the local ground, not by heights another globe sampled', async () => { const offsets = [0.004, 0.012, 0.02]; @@ -156,7 +162,7 @@ test('the handoff pass on a loading globe refines once its surface is ready', as assert.equal(paints.at(-1).label, 'Handoff', 'not ready: no refinement yet'); surface.ready = true; surface.frame(); - await settle(); + await settle(() => paints.at(-1)?.label === 'Handoff refined'); assert.equal(paints.at(-1).label, 'Handoff refined'); for (const r of roads) assert.ok(