firebase / firebase/firebase-js-sdk
`onConfigUpdated` emits error when the page becomes hidden
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### Operating System
macOS Sequoia
### Environment (if applicable)
Chrome
### Firebase SDK Version
12.6.0
### Firebase SDK Product(s)
Remote-Config
### Project Tooling
none.
(I use flutter firebase lib for flutter web and noticed this behavior: https://github.com/firebase/flutterfire/issues/17901 )
### Detailed Problem Description
`onConfigUpdated` with error handler emits the following error repeatedly when the page becomes hidden (e.g. switching tabs or minimizing the browser window):
```
FirebaseError: Remote Config: The stream was not able to connect to the backend: Unable to connect to the server. HTTP status code: undefined. (remoteconfig/stream-error).
at RealtimeHandler.prepareAndBeginRealtimeHttpStream (realtime_handler.ts:633:35)
```
Since the SDK already tracks background state via `isInBackground`, would it make sense to guard [this else block](https://github.com/firebase/firebase-js-sdk/blob/bc2b2cdeae920ff22aca3414c2a1b79d4a3b1351/packages/remote-config/src/client/realtime_handler.ts#L628) as well?
### Steps and code to reproduce issue
```js
import { initializeApp } from "https://www.gstatic.com/firebasejs/12.6.0/firebase-app.js"
import { getRemoteConfig, onConfigUpdate } from "https://www.gstatic.com/firebasejs/12.6.0/firebase-remote-config.js"
const firebaseConfig = {
// config
};
const app = initializeApp(firebaseConfig);
const remoteConfig = getRemoteConfig(app);
onConfigUpdate(remoteConfig, {
next: (configUpdate) => {
console.log("Updated keys:", configUpdate.getUpdatedKeys());
},
error: (error) => {
console.error(error);
},
complete: () => {
console.log("Listening stopped.");
}
});
```
1. Load js
2. Switch tab
Contributor guide
Assessment
This issue has not been assessed yet.