@firebase/data-connect 0.7.2 → 0.7.3

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.
@@ -312,7 +312,8 @@ async function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken,
312
312
  }
313
313
  const headers = {
314
314
  'Content-Type': 'application/json',
315
- 'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen, _callerSdkType)
315
+ 'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen, _callerSdkType),
316
+ 'X-Client-Version': `web/${SDK_VERSION}`
316
317
  };
317
318
  if (accessToken) {
318
319
  headers['X-Firebase-Auth-Token'] = accessToken;
@@ -531,13 +532,9 @@ const IDLE_CONNECTION_TIMEOUT_MS = 15 * 1000; // 15 seconds
531
532
  /** Initial reconnect delay in ms */
532
533
  const INITIAL_RECONNECT_DELAY_MS = 1000; // 1 second
533
534
  /** Max reconnect delay in ms */
534
- const MAX_RECONNECT_DELAY_MS = 30 * 1000; // 30 seconds
535
- /** Max random jitter to add to reconnect delay in ms */
536
- const MAX_RECONNECT_JITTER_MS = 0.5 * 1000; // 0.5 seconds
535
+ const MAX_RECONNECT_DELAY_MS = 60 * 1000; // 60 seconds
537
536
  /** Factor to multiply delay by on failure */
538
- const RECONNECT_BACKOFF_FACTOR = 1.3;
539
- /** Max number of reconnection attempts before giving up */
540
- const MAX_RECONNECT_ATTEMPTS = 10;
537
+ const RECONNECT_BACKOFF_FACTOR = 1.5;
541
538
  /**
542
539
  * The base class for all Stream Transport implementations.
543
540
  * Handles management of logical streams (requests), authentication, data routing to query layer,
@@ -789,15 +786,10 @@ class AbstractDataConnectStreamTransport extends AbstractDataConnectTransport {
789
786
  if (this.reconnectTimer) {
790
787
  return;
791
788
  }
792
- if (this.reconnectAttempts++ >= MAX_RECONNECT_ATTEMPTS) {
793
- const errorString = 'Stream disconnected and could not reconnect - max stream reconnection attempts reached.';
794
- logError(errorString);
795
- void this.cleanupAndTerminate(Code.OTHER, errorString);
796
- return;
797
- }
789
+ this.reconnectAttempts++;
798
790
  const delay = this.reconnectDelayMs;
799
791
  this.reconnectDelayMs = Math.min(this.reconnectDelayMs * RECONNECT_BACKOFF_FACTOR, MAX_RECONNECT_DELAY_MS);
800
- const jitter = Math.random() * MAX_RECONNECT_JITTER_MS;
792
+ const jitter = (Math.random() - 0.5) * delay;
801
793
  this.reconnectTimer = setTimeout(() => {
802
794
  this.reconnectTimer = null;
803
795
  void this.attemptReconnect();
@@ -959,6 +951,7 @@ class AbstractDataConnectStreamTransport extends AbstractDataConnectTransport {
959
951
  this.lastSentAuthToken = this._authToken;
960
952
  }
961
953
  if (this.isFirstStreamMessage) {
954
+ headers['X-Client-Version'] = `web/${SDK_VERSION}`;
962
955
  if (this._appCheckToken) {
963
956
  headers['X-Firebase-App-Check'] = this._appCheckToken;
964
957
  }
@@ -1561,7 +1554,7 @@ class WebSocketTransport extends AbstractDataConnectStreamTransport {
1561
1554
  }
1562
1555
 
1563
1556
  const name = "@firebase/data-connect";
1564
- const version = "0.7.2";
1557
+ const version = "0.7.3";
1565
1558
 
1566
1559
  /**
1567
1560
  * @license