@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.
package/dist/index.esm.js CHANGED
@@ -4,7 +4,7 @@ import { FirebaseError, generateSHA256Hash, isCloudWorkstation, pingServer } fro
4
4
  import { Logger } from '@firebase/logger';
5
5
 
6
6
  const name = "@firebase/data-connect";
7
- const version = "0.7.2";
7
+ const version = "0.7.3";
8
8
 
9
9
  /**
10
10
  * @license
@@ -1448,7 +1448,8 @@ async function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken,
1448
1448
  }
1449
1449
  const headers = {
1450
1450
  'Content-Type': 'application/json',
1451
- 'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen, _callerSdkType)
1451
+ 'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen, _callerSdkType),
1452
+ 'X-Client-Version': `web/${SDK_VERSION}`
1452
1453
  };
1453
1454
  if (accessToken) {
1454
1455
  headers['X-Firebase-Auth-Token'] = accessToken;
@@ -1667,13 +1668,9 @@ const IDLE_CONNECTION_TIMEOUT_MS = 15 * 1000; // 15 seconds
1667
1668
  /** Initial reconnect delay in ms */
1668
1669
  const INITIAL_RECONNECT_DELAY_MS = 1000; // 1 second
1669
1670
  /** Max reconnect delay in ms */
1670
- const MAX_RECONNECT_DELAY_MS = 30 * 1000; // 30 seconds
1671
- /** Max random jitter to add to reconnect delay in ms */
1672
- const MAX_RECONNECT_JITTER_MS = 0.5 * 1000; // 0.5 seconds
1671
+ const MAX_RECONNECT_DELAY_MS = 60 * 1000; // 60 seconds
1673
1672
  /** Factor to multiply delay by on failure */
1674
- const RECONNECT_BACKOFF_FACTOR = 1.3;
1675
- /** Max number of reconnection attempts before giving up */
1676
- const MAX_RECONNECT_ATTEMPTS = 10;
1673
+ const RECONNECT_BACKOFF_FACTOR = 1.5;
1677
1674
  /**
1678
1675
  * The base class for all Stream Transport implementations.
1679
1676
  * Handles management of logical streams (requests), authentication, data routing to query layer,
@@ -1925,15 +1922,10 @@ class AbstractDataConnectStreamTransport extends AbstractDataConnectTransport {
1925
1922
  if (this.reconnectTimer) {
1926
1923
  return;
1927
1924
  }
1928
- if (this.reconnectAttempts++ >= MAX_RECONNECT_ATTEMPTS) {
1929
- const errorString = 'Stream disconnected and could not reconnect - max stream reconnection attempts reached.';
1930
- logError(errorString);
1931
- void this.cleanupAndTerminate(Code.OTHER, errorString);
1932
- return;
1933
- }
1925
+ this.reconnectAttempts++;
1934
1926
  const delay = this.reconnectDelayMs;
1935
1927
  this.reconnectDelayMs = Math.min(this.reconnectDelayMs * RECONNECT_BACKOFF_FACTOR, MAX_RECONNECT_DELAY_MS);
1936
- const jitter = Math.random() * MAX_RECONNECT_JITTER_MS;
1928
+ const jitter = (Math.random() - 0.5) * delay;
1937
1929
  this.reconnectTimer = setTimeout(() => {
1938
1930
  this.reconnectTimer = null;
1939
1931
  void this.attemptReconnect();
@@ -2095,6 +2087,7 @@ class AbstractDataConnectStreamTransport extends AbstractDataConnectTransport {
2095
2087
  this.lastSentAuthToken = this._authToken;
2096
2088
  }
2097
2089
  if (this.isFirstStreamMessage) {
2090
+ headers['X-Client-Version'] = `web/${SDK_VERSION}`;
2098
2091
  if (this._appCheckToken) {
2099
2092
  headers['X-Firebase-App-Check'] = this._appCheckToken;
2100
2093
  }