stream-chat 9.54.2 → 9.54.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat",
3
- "version": "9.54.2",
3
+ "version": "9.54.4",
4
4
  "description": "JS SDK for the Stream Chat API",
5
5
  "homepage": "https://getstream.io/chat/",
6
6
  "author": {
@@ -460,10 +460,14 @@ export class ChannelManager extends WithSubscriptions {
460
460
  });
461
461
 
462
462
  if (channelsFromDB) {
463
- const offlineChannels = this.client.hydrateActiveChannels(channelsFromDB, {
464
- offlineMode: true,
465
- skipInitialization: [], // passing empty array will clear out the existing messages from channel state, this removes the possibility of duplicate messages
466
- });
463
+ const offlineChannels = this.client.hydrateActiveChannels(
464
+ channelsFromDB,
465
+ {
466
+ offlineMode: true,
467
+ skipInitialization: [], // passing empty array will clear out the existing messages from channel state, this removes the possibility of duplicate messages
468
+ },
469
+ options,
470
+ );
467
471
 
468
472
  this.state.partialNext({ channels: offlineChannels });
469
473
  }
package/src/connection.ts CHANGED
@@ -416,7 +416,21 @@ export class StableWSConnection {
416
416
  this._destroyCurrentWSConnection();
417
417
 
418
418
  if (options.refreshToken) {
419
- await this.client.tokenManager.loadToken();
419
+ try {
420
+ await this.client.tokenManager.loadToken();
421
+ } catch (error) {
422
+ // _reconnect() is not awaited by its callers, so a rejection here would be unhandled.
423
+ // Treat a failed refresh like a failed connect and retry with backoff.
424
+ this.isHealthy = false;
425
+ this.consecutiveFailures += 1;
426
+ this._log('_reconnect() - Failed to refresh the token', { error }, 'warn');
427
+
428
+ if (!this.isDisconnected) {
429
+ this._log('_reconnect() - Going to try to reload token and reconnect');
430
+ this._reconnect({ refreshToken: true });
431
+ }
432
+ return;
433
+ }
420
434
 
421
435
  // Another reconnect may have started while the token was loading, e.g. when
422
436
  // the socket fires both an error and a close event.