Run pass now, then once per interval_ms, until stop is called.
- Startup pass. The first pass starts before this returns; later passes
follow one
interval_ms apart, start to start. - A slow pass delays the schedule. Passes never overlap, and a pass that
overruns its interval pushes the next one back: the next pass starts when
the slow one ends, the one after a full
interval_ms later — no burst of
catch-up passes. - A failed pass is logged, never fatal. A pass that throws or rejects
is logged at
warn with name and the error object itself — so the log
carries its stack and its cause — and the loop goes on to the next
interval, so an outage is retried rather than ending the upkeep for the
life of the process. stop finishes the pass in progress. It ends the schedule at once and
resolves when a pass in progress has finished; nothing is dropped
mid-flight.
The timer is unref'd where the runtime hands back a timer object (Node,
Bun), so a task nobody stopped does not hold the process open.
pass is called once per pass and returns that pass's promise. name
labels the task in the failure log.
Twin of the Rust spawn_periodic. The schedule is that loop's
MissedTickBehavior::Delay. Shutdown differs: the Rust task drops a pass
in progress when its token is cancelled, so joining it is prompt and a pass
must be safe to drop; here the pass runs to its end and stop waits for it.