@firebase/remote-config 0.9.2 → 0.9.3-20260929175154

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.
@@ -5,7 +5,7 @@ import { LogLevel, Logger } from '@firebase/logger';
5
5
  import '@firebase/installations';
6
6
 
7
7
  const name = "@firebase/remote-config";
8
- const version = "0.9.2";
8
+ const version = "0.9.3-20260929175154";
9
9
 
10
10
  /**
11
11
  * @license
@@ -2063,26 +2063,45 @@ class RealtimeHandler {
2063
2063
  }
2064
2064
  }
2065
2065
  finally {
2066
+ // Capture the visibility state before closing the connection. Closing is
2067
+ // asynchronous, so the app may return to the foreground before it completes,
2068
+ // and an expected background close would then be misread as a failure.
2069
+ const wasInBackground = this.isInBackground;
2066
2070
  // Close HTTP connection and associated streams.
2067
2071
  await this.closeRealtimeHttpConnection();
2068
2072
  this.setIsHttpConnectionRunning(false);
2069
- // Update backoff metadata if the connection failed in the foreground.
2070
- const connectionFailed = !this.isInBackground &&
2071
- (responseCode === undefined ||
2072
- this.isStatusCodeRetryable(responseCode));
2073
- if (connectionFailed) {
2074
- await this.updateBackoffMetadataWithLastFailedStreamConnectionTime(new Date());
2075
- }
2076
- // If responseCode is null then no connection was made to server and the SDK should still retry.
2077
- if (connectionFailed || response?.ok) {
2078
- await this.retryHttpConnectionWhenBackoffEnds();
2079
- }
2080
- else {
2081
- const errorMessage = `Unable to connect to the server. HTTP status code: ${responseCode}`;
2082
- const firebaseError = ERROR_FACTORY.create("stream-error" /* ErrorCode.CONFIG_UPDATE_STREAM_ERROR */, {
2083
- originalErrorMessage: errorMessage
2084
- });
2085
- this.propagateError(firebaseError);
2073
+ // Nothing to do while the app is hidden. A retry cannot run, and recording a
2074
+ // backoff penalty would persist a failure that never happened.
2075
+ if (!this.isInBackground) {
2076
+ if (wasInBackground) {
2077
+ // The connection was closed because the app moved to the background, and
2078
+ // the app returned to the foreground before the teardown finished. The
2079
+ // reconnect attempted at that point was skipped because this connection
2080
+ // was still active, so it has to be made here. Backgrounding is not a
2081
+ // failure, so restore the retry budget rather than spending it, which
2082
+ // also keeps an exhausted budget from surfacing a stream error.
2083
+ this.resetRetryCount();
2084
+ await this.retryHttpConnectionWhenBackoffEnds();
2085
+ }
2086
+ else {
2087
+ // Update backoff metadata if the connection failed in the foreground.
2088
+ const connectionFailed = responseCode === undefined ||
2089
+ this.isStatusCodeRetryable(responseCode);
2090
+ if (connectionFailed) {
2091
+ await this.updateBackoffMetadataWithLastFailedStreamConnectionTime(new Date());
2092
+ }
2093
+ // If responseCode is null then no connection was made to server and the SDK should still retry.
2094
+ if (connectionFailed || response?.ok) {
2095
+ await this.retryHttpConnectionWhenBackoffEnds();
2096
+ }
2097
+ else {
2098
+ const errorMessage = `Unable to connect to the server. HTTP status code: ${responseCode}`;
2099
+ const firebaseError = ERROR_FACTORY.create("stream-error" /* ErrorCode.CONFIG_UPDATE_STREAM_ERROR */, {
2100
+ originalErrorMessage: errorMessage
2101
+ });
2102
+ this.propagateError(firebaseError);
2103
+ }
2104
+ }
2086
2105
  }
2087
2106
  }
2088
2107
  }