Skip to main content
Version: v0.0.3

Interface: RetryContext

Context passed to a custom retryStrategy hook on each reconnect attempt.

Frozen via Object.freeze before invocation, handlers cannot mutate.

Example

const retryStrategy: RetryStrategy = (ctx) => {
if (ctx.attempt >= 5) return null;
if (ctx.classifiedAs === 'permanent') return null;
return Math.min(30_000, 1000 * (ctx.attempt + 1));
};

Properties

attempt

readonly attempt: number

0-indexed attempt counter for the current reconnect cycle.


classifiedAs

readonly classifiedAs: "transient" | "permanent"

How the failure that triggered this reconnect attempt was classified.


lastDelayMs

readonly lastDelayMs: number

Delay used for the previous attempt (ms). 0 on the first attempt.


lastError

readonly lastError: Error

The error that triggered the disconnect.


signal

readonly signal: AbortSignal

The same AbortSignal passed into connect(). If no signal was supplied, the module-level NEVER_ABORTING_SIGNAL sentinel is provided so handlers always have a real AbortSignal to inspect.


sinceLastSuccessMs

readonly sinceLastSuccessMs: number

Ms since the last successful ACK. Infinity if no success seen.


totalElapsedMs

readonly totalElapsedMs: number

Total wall-clock ms elapsed since the disconnect that started this cycle.