-
Notifications
You must be signed in to change notification settings - Fork 32
6.2.3 is completely broken on Android #157
Description
Describe the bug
6.2.3 is completely broken for Android
To reproduce
Launch ManualTestApp on Android using 6.2.3
Observe in console ERROR [Error: LaunchDarkly SDK already initialized] immediately after run.
Expected behavior
Calling .configure(...) should not resolve into an LaunchDarkly SDK already initialized error neither at the start of the app, nor after we call .close() and then .configure(...) again.
SDK version
6.2.3
OS/platform
Android 12
Additional context
This happens because .isInitialized(...) used to return a rejected Promise, when client is not available and since 6.2.3 (as pointed here) it resolves with false.
If you look on the code below, you'll see, that if .isInitialized(...) is not rejected -> we throw an error, but right we do not reject it, hence we see a vicious cycle.
On 6.2.2 .isInitialized(...) would resolve with false after you've called .close() instead of rejecting (see here this issue).
So, 6.2.3 is completely unusable on Android.
react-native-client-sdk/index.js
Lines 21 to 43 in 0754d67
| configure(config, user, timeout) { | |
| return LaunchdarklyReactNativeClient.isInitialized("default") | |
| .then( | |
| ignored => { | |
| throw new Error('LaunchDarkly SDK already initialized'); | |
| }, | |
| () => { | |
| const configWithOverriddenDefaults = Object.assign({ | |
| backgroundPollingIntervalMillis: 3600000, // the iOS SDK defaults this to 900000 | |
| disableBackgroundUpdating: false, // the iOS SDK defaults this to true | |
| pollUri: 'https://clientsdk.launchdarkly.com', | |
| wrapperName: 'react-native-client-sdk', | |
| wrapperVersion: this.getVersion() | |
| }, config); | |
| if (timeout == undefined) { | |
| return LaunchdarklyReactNativeClient.configure(configWithOverriddenDefaults, user); | |
| } else { | |
| return LaunchdarklyReactNativeClient.configureWithTimeout(configWithOverriddenDefaults, user, timeout); | |
| } | |
| } | |
| ); | |
| } |