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

fix: Fix evaluation race between status and flag fields #29

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

keelerm84
Copy link
Member

When the SDK is first initializing, the flag field is set before the status field on the LaunchDarkly node. As a result, listeners on the flag field would be executed before the status field is changed.

If a flag change listener tries to evaluate a flag the first time a change is triggered, the default value will be returned along with an error that the client isn't ready since the SDK doesn't think it is initialized.

To fix this, evaluation is allowed to continue if the SDK is initialized or if the store has flag data present. This is inline with other mobile SDKs.

When the SDK is first initializing, the flag field is set before the
status field on the LaunchDarkly node. As a result, listeners on the
flag field would be executed before the status field is changed.

If a flag change listener tries to evaluate a flag the first time a
change is triggered, the default value will be returned along with an
error that the client isn't ready since the SDK doesn't think it is
initialized.

To fix this, evaluation is allowed to continue if the SDK is initialized
or if the store has flag data present. This is inline with other mobile
SDKs.
@keelerm84 keelerm84 requested a review from a team April 9, 2024 20:16
},

initialized: function() as Boolean
Copy link
Member

Choose a reason for hiding this comment

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

Both implementations being in the same file makes this so confusing.

@keelerm84 keelerm84 merged commit 2677895 into main Apr 10, 2024
2 checks passed
@keelerm84 keelerm84 deleted the mk/sc-234503/race-condition branch April 10, 2024 14:17
keelerm84 pushed a commit that referenced this pull request Apr 10, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.1.1](2.1.0...2.1.1)
(2024-04-10)


### Bug Fixes

* Fix evaluation race between status and flag fields
([#29](#29))
([2677895](2677895))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants