@@ -253,7 +253,11 @@ export class WebSocketManager {
253
253
}
254
254
this . logger . log ( msg ) ;
255
255
}
256
- this . scheduleReconnect ( ) ;
256
+ if ( event . reason ?. includes ( "SubscriptionsWorkerFullError" ) ) {
257
+ this . scheduleReconnect ( "SubscriptionsWorkerFullError" ) ;
258
+ } else {
259
+ this . scheduleReconnect ( "unknown" ) ;
260
+ }
257
261
return ;
258
262
} ;
259
263
}
@@ -320,9 +324,11 @@ export class WebSocketManager {
320
324
} , this . serverInactivityThreshold ) ;
321
325
}
322
326
323
- private scheduleReconnect ( ) {
327
+ private scheduleReconnect (
328
+ reason : "client" | "unknown" | "SubscriptionsWorkerFullError" ,
329
+ ) {
324
330
this . socket = { state : "disconnected" } ;
325
- const backoff = this . nextBackoff ( ) ;
331
+ const backoff = this . nextBackoff ( reason ) ;
326
332
this . logger . log ( `Attempting reconnect in ${ backoff } ms` ) ;
327
333
setTimeout ( ( ) => this . connect ( ) , backoff ) ;
328
334
}
@@ -345,7 +351,7 @@ export class WebSocketManager {
345
351
this . lastCloseReason = closeReason ;
346
352
// Close the old socket asynchronously, we'll open a new socket in reconnect.
347
353
void this . close ( ) ;
348
- this . scheduleReconnect ( ) ;
354
+ this . scheduleReconnect ( "client" ) ;
349
355
return ;
350
356
}
351
357
default : {
@@ -543,8 +549,12 @@ export class WebSocketManager {
543
549
this . logger . logVerbose ( message ) ;
544
550
}
545
551
546
- private nextBackoff ( ) : number {
547
- const baseBackoff = this . initialBackoff * Math . pow ( 2 , this . retries ) ;
552
+ private nextBackoff (
553
+ reason : "client" | "unknown" | "SubscriptionsWorkerFullError" ,
554
+ ) : number {
555
+ const initialBackoff =
556
+ reason === "SubscriptionsWorkerFullError" ? 3000 : this . initialBackoff ;
557
+ const baseBackoff = initialBackoff * Math . pow ( 2 , this . retries ) ;
548
558
this . retries += 1 ;
549
559
const actualBackoff = Math . min ( baseBackoff , this . maxBackoff ) ;
550
560
const jitter = actualBackoff * ( Math . random ( ) - 0.5 ) ;
0 commit comments