@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.cjs.js CHANGED
@@ -8,7 +8,7 @@ var util = require('@firebase/util');
8
8
  var logger$1 = require('@firebase/logger');
9
9
 
10
10
  const name = "@firebase/data-connect";
11
- const version = "0.7.2";
11
+ const version = "0.7.3";
12
12
 
13
13
  /**
14
14
  * @license
@@ -1452,7 +1452,8 @@ async function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken,
1452
1452
  }
1453
1453
  const headers = {
1454
1454
  'Content-Type': 'application/json',
1455
- 'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen, _callerSdkType)
1455
+ 'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen, _callerSdkType),
1456
+ 'X-Client-Version': `web/${SDK_VERSION}`
1456
1457
  };
1457
1458
  if (accessToken) {
1458
1459
  headers['X-Firebase-Auth-Token'] = accessToken;
@@ -1671,13 +1672,9 @@ const IDLE_CONNECTION_TIMEOUT_MS = 15 * 1000; // 15 seconds
1671
1672
  /** Initial reconnect delay in ms */
1672
1673
  const INITIAL_RECONNECT_DELAY_MS = 1000; // 1 second
1673
1674
  /** Max reconnect delay in ms */
1674
- const MAX_RECONNECT_DELAY_MS = 30 * 1000; // 30 seconds
1675
- /** Max random jitter to add to reconnect delay in ms */
1676
- const MAX_RECONNECT_JITTER_MS = 0.5 * 1000; // 0.5 seconds
1675
+ const MAX_RECONNECT_DELAY_MS = 60 * 1000; // 60 seconds
1677
1676
  /** Factor to multiply delay by on failure */
1678
- const RECONNECT_BACKOFF_FACTOR = 1.3;
1679
- /** Max number of reconnection attempts before giving up */
1680
- const MAX_RECONNECT_ATTEMPTS = 10;
1677
+ const RECONNECT_BACKOFF_FACTOR = 1.5;
1681
1678
  /**
1682
1679
  * The base class for all Stream Transport implementations.
1683
1680
  * Handles management of logical streams (requests), authentication, data routing to query layer,
@@ -1929,15 +1926,10 @@ class AbstractDataConnectStreamTransport extends AbstractDataConnectTransport {
1929
1926
  if (this.reconnectTimer) {
1930
1927
  return;
1931
1928
  }
1932
- if (this.reconnectAttempts++ >= MAX_RECONNECT_ATTEMPTS) {
1933
- const errorString = 'Stream disconnected and could not reconnect - max stream reconnection attempts reached.';
1934
- logError(errorString);
1935
- void this.cleanupAndTerminate(Code.OTHER, errorString);
1936
- return;
1937
- }
1929
+ this.reconnectAttempts++;
1938
1930
  const delay = this.reconnectDelayMs;
1939
1931
  this.reconnectDelayMs = Math.min(this.reconnectDelayMs * RECONNECT_BACKOFF_FACTOR, MAX_RECONNECT_DELAY_MS);
1940
- const jitter = Math.random() * MAX_RECONNECT_JITTER_MS;
1932
+ const jitter = (Math.random() - 0.5) * delay;
1941
1933
  this.reconnectTimer = setTimeout(() => {
1942
1934
  this.reconnectTimer = null;
1943
1935
  void this.attemptReconnect();
@@ -2099,6 +2091,7 @@ class AbstractDataConnectStreamTransport extends AbstractDataConnectTransport {
2099
2091
  this.lastSentAuthToken = this._authToken;
2100
2092
  }
2101
2093
  if (this.isFirstStreamMessage) {
2094
+ headers['X-Client-Version'] = `web/${SDK_VERSION}`;
2102
2095
  if (this._appCheckToken) {
2103
2096
  headers['X-Firebase-App-Check'] = this._appCheckToken;
2104
2097
  }