Skip to main content

Module timers

Module timers 

Source
Expand description

setTimeout / setInterval / clearTimeout / clearInterval / setImmediate / queueMicrotask — native, ctx.spawn-backed (the timer future lives on the host’s VM executor, so callbacks fire between executes and while a script is parked on a host await; dropping the runtime aborts every armed timer).

The timer handle is a Timeout class instance (not a numeric id): it survives REPL-style across evaluations via globalThis and clearTimeout(handle) cancels through its Notify. Holding the JS callback inside the spawned future is the sanctioned executor-owned-future shape (same as AbortSignal.timeout) — the future is dropped with the runtime, never stored in a traced JS field.

A host with ambient per-callback state (a capability grant, a request scope) supplies it as a CallbackPolicy: it is captured when the timer is armed and re-entered when the callback fires, so a callback registered under a restriction keeps it instead of falling back to whatever the resting state happens to be. Hosts without such state install NoPolicy.

Structs§

NoPolicy
For hosts with no ambient callback state: callbacks run as they are.
Timeout
Opaque timer handle returned by setTimeout / setInterval.

Traits§

CallbackPolicy
Ambient host state that a scheduled callback must run under.

Functions§

install
Install the timer globals, carrying P from registration to callback.