Skip to main content

Function: sleepUnref()

sleepUnref(ms: number, signal?: AbortSignal): Promise<void>

Defined in: shared/utils/abortUtils.ts:349

Promise-based sleep helper with AbortSignal support that does not keep the Node.js event loop alive.

Parametersโ€‹

msโ€‹

number

Delay duration in milliseconds.

signal?โ€‹

AbortSignal

Optional cancellation signal to observe.

Returnsโ€‹

Promise<void>

Remarksโ€‹

This behaves like sleep, but when running in Node.js / Electron it will call unref() on the underlying timer handle when available.

Prefer this for best-effort background waits (for example, retry delays) where you do not want the process to stay alive solely because a sleep is pending.