Skip to content

Commit 8c75849

Browse files
committed
fix(remote-config, ios): workaround firebase-ios-sdk#11458 until SDK v10.12.0
the impact of the workaround is that on iOS, if you subscribe to remote-config realtime updates at all, the web socket to listen for updates will be opened and never closed, even if you unsubscribe all listeners this should be reverted when 10.12.0 is adopted
1 parent 90fc7b7 commit 8c75849

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

docs/remote-config/usage/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ in applications that attach one or more listeners for them.
190190
### Known Issues
191191

192192
1. **_Handle errors / retry in callback_** During testing here in react-native-firebase, we frequently received the "config_update_not_fetched" error when performing updates and fetching them rapidly. This may not occur in normal usage but be sure to include error handling code in your callback. If this error is raised, you should be able to fetch and activate the new config template with retries after a timeout. Tracked as https://github.com/firebase/firebase-ios-sdk/issues/11462 and a fix is anticipated in firebase-ios-sdk 10.12.0
193+
1. **_iOS web socket will never close_** During testing here in react-native-firebase, we identified a problem in firebase-ios-sdk where native listeners are not removed when you attempt to unsubscribe them, resulting in more update events than expected. As a temporary workaround to avoid the issue, we create a native listener on iOS the first time you subscribe to realtime update events, and we never remove the listener, even if you unsubscribe it. That means the web socket will never close once opened. This is tracked as https://github.com/firebase/firebase-ios-sdk/issues/11458 and a fix is anticipated in firebase-ios-sdk 10.12.0
193194

194195
Here is an example of how to use the feature, with comments emphasizing the key points to know:
195196

packages/remote-config/lib/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,13 @@ class FirebaseConfigModule extends FirebaseModule {
325325
}
326326
subscription.remove();
327327
this._configUpdateListenerCount--;
328-
if (this._configUpdateListenerCount === 0) {
328+
// In firebase-ios-sdk, it appears listener removal fails, so our native listeners accumulate
329+
// if we try to remove them. Temporarily allow iOS native listener to stay active forever after
330+
// first subscription for an app, until issue #11458 in firebase-ios-sdk repo is resolved.
331+
// react-native-firebase native subscribe code won't add multiple native listeners for same app,
332+
// so this prevents listener accumulation but means the web socket on iOS will never close.
333+
// TODO: Remove when firebase-ios-sdk 10.12.0 is adopted, the PR to fix it should be included
334+
if (this._configUpdateListenerCount === 0 && Platform.OS !== 'ios') {
329335
this.native.removeConfigUpdateRegistration();
330336
}
331337
};

0 commit comments

Comments
 (0)