launchdarkly / ios-client-sdk

LaunchDarkly Client-side SDK for iOS (Swift and Obj-C)
https://docs.launchdarkly.com/sdk/client-side/ios
Other
68 stars 84 forks source link

LDClient `identify` completion handler is never invoked when there are network connectivity issues #264

Closed SD10 closed 4 months ago

SD10 commented 2 years ago

Describe the bug The identify method of LDClient never invokes its completion block parameter in situations of poor connectivity that cause the underlying network requests to fail

To reproduce

let user = LDUser(key: "1")
LDClient.get().identify(user) {
    print("Call me maybe")
}

Expected behavior The identify method should call its completion handler after a specified timeout and cause the print to be executed.

Logs

SDK version 5.4.5

Language version, developer tools Xcode 13, Swift 5

OS/platform iOS 15

Additional context The LDClient documentation states:

A completion may be passed to the identify method to allow a client app to know when fresh flag values for the new user are ready.

and

completion: Closure called when the embedded setOnlineIdentify call completes, subject to throttling delays. (Optional)

This makes it dangerous to block user progression in the application using the identify method since it will never timeout in the case of network connectivity issues or issues with the Launch Darkly service.

  1. Adding a timeout parameter to the identify method to would help mitigate this issue
  2. Adding additional context to the completion handler such as a boolean flag indicating whether the completion handler is being invoked in the scenario of success or failure would be very useful for error handling as well

Related issues: #211, #209

Thank you 🙏

louis-launchdarkly commented 2 years ago

Hello @SD10, thank you for reaching out, and sorry for the late response - from your description and the related issues, we could be missing some connectivity handling when you call identify. Let me discuss this with the team and get back to you once we have a better understanding of the issue.

taraspasichnyk commented 2 years ago

Our team experiences that as well. Are there any updates?

louis-launchdarkly commented 2 years ago

Hello @SD10 and @taraspasichnyk, thank you for reaching out.

We are still investigating, but have not yet determined the best course of action.

Ideally, the API would both lend itself to correct usage and also allow differentiation between a successful identify and a timeout. Also, we may need additional handling that allows us to notice when a condition is likely not going to recover in a timely manner.

We will provide an update, either in guidance for an alternate way to use the API or as an SDK update, when we can.

simondelphia commented 11 months ago

There's now a startWaitSeconds parameter, and the completion block has a timedOut parameter as well. So presumably this can be closed?

fred-riverside commented 9 months ago

Same issue here at Riverside...

YoavGro commented 9 months ago

@louis-launchdarkly any update on this?

keelerm84 commented 4 months ago

In the recently released v9.4.0, we introduced a new identify method which accepts a timeout interval. If an identify request does not complete within that time frame, the provided callback will be triggered with a result value of .timeout.