Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing crashes when using overflowing values #246

Merged
merged 1 commit into from
Jun 11, 2021
Merged

Fixing crashes when using overflowing values #246

merged 1 commit into from
Jun 11, 2021

Conversation

delannoyk
Copy link
Contributor

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

I didn't create a GitHub issue for this, but happy to if necessary.

Describe the solution you've provided

Int(exactly:) will return nil in case of an overflow whereas Int(_:) will just crash. When converting the Double to an Int, if it fails, we now use Int.max as a rescue.

Describe alternatives you've considered

Fixing the crash was I think necessary. That being said, we only noticed that crash because we wanted to disable updates to our feature flags during a user session (we want to have a consistent experience throughout the session). There's no way that I could find to do that right now, so we opted for having a really long update interval.
Adding this feature would have been nice too, but was more work that I intended.

Additional context

Nothing else from me.

@torchhound
Copy link
Contributor

Hi @delannoyk thanks for submitting this PR! We will review this internally to check if this fits with intended SDK behavior.

@bwoskow-ld
Copy link
Member

Hi @delannoyk,

While our SDK team hasn't yet had a chance to look at this issue, I did want to recommend that you use smaller intervals if you haven't already done so. Our SDK isn't really designed to operate with "really long" intervals because, depending on which intervals you extends, flag values will be stale (which is actually your intent here) and the event buffer is more likely to overflow and start dropping events.

If you choose to proceed with large intervals, consider setting them to the max int value so as to avoid running into this crash.

Cheers,
@bwoskow-ld

Copy link
Contributor

@gwhelanLD gwhelanLD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks! We'll get a patch out with this change soon.

Thanks,
@gwhelanLD

@gwhelanLD gwhelanLD merged commit fcfe002 into launchdarkly:v5 Jun 11, 2021
@gwhelanLD
Copy link
Contributor

Thanks again for the contribution! It's been included in the 5.4.2 release.

Thanks,
@gwhelanLD

@delannoyk
Copy link
Contributor Author

Thank you for the update 👍🏻

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

Successfully merging this pull request may close these issues.

4 participants