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