Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Methods called on Client after calling .close() throw errors on iOS #75

Closed
shaneboyar opened this issue Apr 28, 2021 · 4 comments
Closed

Comments

@shaneboyar
Copy link

Is this a support request?
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going here or by emailing support@launchdarkly.com.

Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.

Describe the bug
Given an instantiated client LDClient, calling .close() will cause any future method calls on that client to throw an error in from the swift code.

To reproduce
Configure a client. Call .close() then try calling a flag check.

Expected behavior
The subsequent flag check should resolve to the given default value.

Logs

LaunchdarklyReactNativeClient.swift:239:31
Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value

(seen this same error on other calls from that class as well)

SDK version
This error was seen on both 4.0.2 and 4.1.1

Language version, developer tools
React Native/Xcode

OS/platform
Error only occurs on iOS, version seems to not matter.

@torchhound
Copy link
Contributor

Hi @shaneboyar this is intended behavior in the underlying iOS SDK. If you rerun configure after close this issue should be resolved.

@shaneboyar
Copy link
Author

Then, unless I've missed it, the docs need to updated since they currently say

Shuts down the client and releases its resources, after delivering any pending analytics events. After the client is closed, all calls to the *Variation methods will return default values, and it will not make any requests to LaunchDarkly.

But it doesn't return the default value, it crashes.

If this is intended, why the force unwrap in the swift code? Why not throw an error if the client isn't available so that the JS side can handle it?

@torchhound
Copy link
Contributor

Then, unless I've missed it, the docs need to updated since they currently say

Shuts down the client and releases its resources, after delivering any pending analytics events. After the client is closed, all calls to the *Variation methods will return default values, and it will not make any requests to LaunchDarkly.

But it doesn't return the default value, it crashes.

If this is intended, why the force unwrap in the swift code? Why not throw an error if the client isn't available so that the JS side can handle it?

This is definitely a bug because Android and iOS behavior has diverged. We will release a fix to make this consistent, thanks for reporting it.

Filed internally as 107608

andvalsol pushed a commit to andvalsol/react-native-client-sdk that referenced this issue May 25, 2021
…l prevent issue launchdarkly#75 (causing a crash when closing the LDClient).
@gwhelanLD
Copy link
Contributor

Hi @shaneboyar,

Changes to fix this consistency issue were included in the 4.2.1 release. This should resolve this issue, but feel free to reach out if you run into any difficulties.

Thanks,
@gwhelanLD

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants