-
Notifications
You must be signed in to change notification settings - Fork 32
LDClient not initialised [Error: LDClient.getForMobileKey() was called before init()!] #186
Comments
Hello @vkundapur, thank you for reaching out about this issue. I will need to discuss this with the engineer on the team who is more familiar with React lifecycle - this seems like the client was accessed too soon (before the initialization). In the meantime, given you are using React Native 0.70, we also recommend you migrated to use the 7.x version of the LaunchDarkly React Native SDK, as that has more stability fixes in addition to the support of Contexts. Filed Internally as 190729. |
Hello @vkundapur, can you try the code with the latest version of the SDK 7.1.2 and see is this still an issue that is happening? We recently released more fixes, and I want to know was that resolved the issue, or if this is still something we need to look into more. |
Thanks @louis-launchdarkly. I'll check and get back to you on this. |
@louis-launchdarkly I am still getting the same error after updating to SDK 7.1.2. |
@louis-launchdarkly Any update on this? Let me know if you need any additional information. |
We're also getting this problem, and it's very annoying because it crashes our |
@louis-launchdarkly @vkundapur For me downgrading to 6.2.2 worked once. i.e. when app is first launched it shows all flags. when quit and restart, it does not show. strange |
Hello @vkundapur, Looking at your code, is there a reason you called LaunchDarkly.client.isInitialized() before calling aunchDarkly.client.configure(ldConfig, user)? Looking at https://github.com/launchdarkly/react-native-client-sdk/blob/main/index.d.ts#L610-L620 - |
@louis-launchdarkly The intent is to see if SDK is already initialise and not call the |
Look at the test app we provided with the SDK https://github.com/launchdarkly/react-native-client-sdk/blob/main/ManualTestApp/App.tsx#L67 I think when you see the client does not exist, you want to do a configure call there:
|
Hello @mikevercoelen and @Soft-Gurus, as I mentioned in the message above, we have a ManualTestApp that demos the init process https://github.com/launchdarkly/react-native-client-sdk/blob/main/ManualTestApp/App.tsx#L30 and I was not able to reproduce the issue using that code, so I would recommend trying to model your init like the test app accordingly. Or if you can provide your code, either on this issue (or if you want privacy, via a Support ticket), we can try to see what's wrong in your case. |
Closing as there is no further feedback/comment. |
Describe the bug
On launch of the app, I am getting the following exception while trying to initialise the SDK in Android.
Launch Darkly LDClient not initialised [Error: LDClient.getForMobileKey() was called before init()!]
To reproduce
Here is the code that are running to initialise the SDK:
Initialisation of the client is done in the code below:
The SDK returns an exception during initialisation but then automatically recovers in the next run as you can see from the logs.
Expected behaviour
There should be no exception thrown.
Logs
'Launch Darkly', 'LDClient not initialised', [Error: SDK has not been configured]
'Launch Darkly', 'Launch Darkly initialised successfully'
SDK version
"launchdarkly-react-native-client-sdk": "^6.3.0",
OS/platform
Android OS v13.0
"react-native": "0.70.5",
The text was updated successfully, but these errors were encountered: