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

Every second request to `identify()` is dropped due to invalid throttling. #240

Closed maciejtrybilo closed 3 years ago

maciejtrybilo commented 3 years ago

Describe the bug

I'm noticing problems with identifying users. Upon launch we always identify an anonymous user with custom flags and then if the user is logged in, or if the user subsequently logs in, we identify the user with LD. However the second request fails to show up in the debugger page and the user isn't identified.

I believe this is due to the faulty behaviour of your throttler.

The Throttler class sets runAttempts to 1 after the first try. Then runAttempts will not be cleared until another run is attempted which will always be dropped and only then runAttempts will be reset to 0 after a delay. So, the third attempt will succeed, but then the fourth will always be dropped and so on.

If I disable throttling, the SDK behaves as expected.

Expected behavior

  1. The runAttempts should be reset eventually after the first attempt.
  2. The requests should not be simply dropped. This leads to behaviour that is very confusing and is overly punitive to the users of the SDK. If the SDK detects that the requests are too frequent, it might drop some of them, but should ensure that at least the last request made will run eventually if only after a delay.

SDK version 5.4.0

Language version, developer tools Xcode 12.4

OS/platform iOS simulator

torchhound commented 3 years ago

Hi @maciejtrybilo thanks for reporting this. We will investigate if this is out of line for our Throttler behavior.

Filed internally as 102007

gwhelanLD commented 3 years ago

Hi @maciejtrybilo,

Thanks for reporting this issue, it should be fixed as of the 5.4.1 release. Please give it a try to verify the issue is resolved. I'll close this issue for now, but feel free to reopen or file a new issue if you continue to experience difficulties with the patch release.

Thanks, @gwhelanLD