Skip to content

GatewayReconnect

Defined in: packages/ws/src/reconnect.ts:107

Reconnect scheduling, backoff and attempt coordination.

new GatewayReconnect(options): GatewayReconnect

Defined in: packages/ws/src/reconnect.ts:118

ReconnectOptions

GatewayReconnect

get attemptPromise(): Promise<void> | undefined

Defined in: packages/ws/src/reconnect.ts:149

The in-flight attempt, or undefined when none is active.

Promise<void> | undefined


get attempts(): number

Defined in: packages/ws/src/reconnect.ts:129

Consecutive attempts made since the last reset.

number


get connecting(): boolean

Defined in: packages/ws/src/reconnect.ts:144

Whether a connection attempt is currently in flight.

boolean


get enabled(): boolean

Defined in: packages/ws/src/reconnect.ts:124

Whether automatic reconnect is permitted.

boolean


get exhausted(): boolean

Defined in: packages/ws/src/reconnect.ts:139

Whether the attempt budget is spent.

boolean


get pending(): boolean

Defined in: packages/ws/src/reconnect.ts:134

Whether a reconnect timer is currently armed.

boolean

attempt(start): Promise<void>

Defined in: packages/ws/src/reconnect.ts:235

Coordinates one logical connection attempt.

Callers that ask while an attempt is in flight join it instead of starting a second: three connect() calls produce one socket attempt and one shared promise.

() => void

Invoked exactly once, when this call begins a new attempt.

Promise<void>


cancel(): void

Defined in: packages/ws/src/reconnect.ts:216

Cancels an armed reconnect. Safe to call when none is armed.

void


canReconnect(): boolean

Defined in: packages/ws/src/reconnect.ts:159

Whether another reconnect is currently allowed.

boolean


classifyClose(code, canResume): CloseAction

Defined in: packages/ws/src/reconnect.ts:154

Classifies a close code against this Gateway’s policy.

number

boolean

CloseAction


reset(): void

Defined in: packages/ws/src/reconnect.ts:222

Clears the attempt counter after a connection succeeds.

void


schedule(run): ScheduleResult

Defined in: packages/ws/src/reconnect.ts:170

Arms a reconnect, unless one is already armed or no attempt is allowed.

Refusing while pending is what keeps repeated closes from stacking timers: several closes in a row produce one reconnect, not several competing sockets.

() => void

ScheduleResult


settle(error?): void

Defined in: packages/ws/src/reconnect.ts:246

Settles the in-flight attempt, resolving it or rejecting with error.

Error

void