Supervisor
Supervisor<
E> =object
Defined in: Core/Supervisor.ts:28
Keeps a fallible task running for the life of a process, restarting it under a retry policy.
One run of the task is one attempt. A successful attempt ends the lifetime as
Stopped("completed"). A failed attempt is restarted after restart.getDelay while the policy’s
when accepts the error and attempts remain; otherwise the lifetime settles with that error and
state Failed.
Example
Section titled “Example”Type Parameters
Section titled “Type Parameters”E = never
Properties
Section titled “Properties”
readonlyabort: () =>void
Defined in: Core/Supervisor.ts:49
Stops the lifetime and waits for the running attempt to settle.
A pending backoff is cancelled immediately; a running attempt receives an aborted signal and
ends the lifetime as Stopped("aborted") when it settles. await lifetime is the shutdown
wait.
Returns
Section titled “Returns”void
Supervisor.run to start the lifetime.
Defined in: Core/Supervisor.ts:38
Starts the lifetime and settles when it ends.
A second call while the lifetime is active returns the same deferred. After the lifetime ends,
a call starts a new one. Aborting the caller’s signal has the same effect as abort.
Parameters
Section titled “Parameters”options?
Section titled “options?”Optional cancellation for the lifetime.
signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Supervisor.abort to stop the lifetime explicitly.
readonlystate: () =>State<E>
Defined in: Core/Supervisor.ts:56
Returns the current lifecycle state.
Returns
Section titled “Returns”State<E>
Supervisor.subscribe to react to changes instead of reading them.
subscribe
Section titled “subscribe”
readonlysubscribe: (listener) => () =>void
Defined in: Core/Supervisor.ts:66
Observes state transitions. Listeners run as the state changes, the final one after the lifetime settles, and they must not throw.
Parameters
Section titled “Parameters”listener
Section titled “listener”(state) => void
The callback invoked with each new state.
Returns
Section titled “Returns”() => void
Supervisor.state to read the current state without subscribing.