launchdarkly / ios-client-sdk

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

`startCompleteWhenFlagsReceived` completion handler is never invoked when there are network connectivity issues #209

Closed robmaceachern closed 4 years ago

robmaceachern commented 4 years ago

Describe the bug The completion handler of startCompleteWhenFlagsReceived is never invoked if there are network connectivity issues that cause the underlying network requests to fail.

This may also be an issue with the completion handler for identify but I haven't confirmed that case.

To reproduce

LDClient.shared.startCompleteWhenFlagsReceived(config: LDConfig(mobileKey: "a-valid-key")) {
    NSLog("LDClient startCompleteWhenFlagsReceived completed")
}

Expected behavior The startCompleteWhenFlagsReceived completion handler should be invoked after some timeout period. The log message should be printed eventually.

Logs The console logs show the underlying requests are timing out but the completion handler isn't invoked at any point while network connectivity is down.

SDK version 4.4.1

Language version, developer tools Xcode 11, Swift 5

OS/platform iOS 13.3

Additional context The documentation states:

// If you need feature flags to load before continuing use the // startCompleteWhenFlagsReceived method with a completion

However it's currently dangerous to block user progress using this method since it will never time out in the case of network connectivity issues or if the launch darkly web service was failing to respond.

A client-configurable timeout value would be very useful for these situations. It may also make sense to provide some kind of success/status flag in the completion handler.

torchhound commented 4 years ago

Hi @robmaceachern, thanks for reporting this issue! We will have a fix out soon.

Filed internally as 66864

gabrieloc commented 4 years ago

FWIW, I am experiencing this issue even without network issues, making this issue especially painful with the latest release which deprecates -start(config:user:completion:)

dannyhertz commented 4 years ago

Any update on when we can expect this issue fixed?

NiltiakSivad commented 4 years ago

Just echoing all the other concerns here. For my specific scenario, since the error is not propagated in the startCompleteWhenFlagsReceived completion callback, we're not able to easily determine if the flags were unsuccessfully retrieved. As a workaround we are having to still rely on the observer callbacks and some very hacky code with timers to ensure our completion is always called.

torchhound commented 4 years ago

Hi all, we have added an additional parameter to startCompleteWhenFlagsReceived that allows you to specify a timeout as requested in version 4.7.0. Please add startWaitSeconds to enable this behavior.