launchdarkly / react-native-client-sdk

LaunchDarkly Client-side SDK for React Native
Other
46 stars 32 forks source link

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

Closed shaneboyar closed 3 years ago

shaneboyar commented 3 years ago

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 commented 3 years ago

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

shaneboyar commented 3 years ago

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 commented 3 years ago

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

gwhelanLD commented 3 years ago

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