The timer wakes up late, finds three overdue beats and plays all three at once. The player does not hear the missing rhythm; they hear a burst.
A JavaScript timer can wake the scheduler, but the Web Audio clock should set the onset time. For disposable clicks, one recovery policy is to skip stale onsets and keep the grid instead of catching up audibly.
A 260 ms interruption
The grid is eight clicks, 100 ms apart. Poll every 25 ms, with no callbacks from 200 ms through 459 ms. In the immediate model, 200, 300 and 400 all fire at 460. With 125 ms lookahead, the poll at 175 has already scheduled 200 and 300; 400 is missed and the next click remains at 500. These are scheduled times in a model, not recorded onsets.
Reproduce the trace
Save as stall.mjs and run node stall.mjs. The same simulated callbacks feed both policies.
import assert from 'node:assert/strict'; const grid = Array.from({length: 8}, (_, i) => (i + 1) * 100); const normal = Array.from({length: 33}, (_, i) => i * 25); const stall = (lo, hi) => [...normal.filter(t => t < lo || t >= hi), hi].sort((a,b) => a-b); function run(polls, ahead, dropStale) { let next = 0; const onsets = [], missed = []; for (const now of polls) { while (next < grid.length && grid[next] <= now + ahead) { const beat = grid[next++]; if (dropStale && beat < now) missed.push(beat); else onsets.push(Math.max(beat, now)); } } return {onsets, missed}; } const long = stall(200, 460); assert.deepEqual(run(long, 0, false), { onsets: [100,460,460,460,500,600,700,800], missed: [] }); assert.deepEqual(run(long, 125, true), { onsets: [100,200,300,500,600,700,800], missed: [400] }); assert.deepEqual(run(stall(200,260),125,true), {onsets:grid, missed:[]}); assert.deepEqual(run(normal,125,true), {onsets:grid, missed:[]}); console.log("All four cases passed"); Bring the policy to a real browser
Treat the interval as a wake-up, not an audio clock. Read AudioContext.currentTime, keep the horizon in seconds and use the same clock for each source’s start(when). Advance a single cursor for every scheduled or discarded beat; overlapping polls must not queue duplicates. Start audio from a user gesture. Log target, queue time and dropped events separately; if you report audible timing, record the output rather than treating the log as a measurement.
A longer lookahead can cover more delays, but queues more events at a tempo you might want to change. Short and long stalls should both be in the test.
An expired click is different from a note-off or a stop request. Those repair system state and should be reconciled, not silently discarded by the click policy.
AI-authored for Sonari Studio. The four timing checks exercise a synthetic Node model, not browser playback or a product benchmark.