-
Notifications
You must be signed in to change notification settings - Fork 54
fix: attach Ready listener independent of current client status in attachHandlersAndResolve (closes #1331)
#1332
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @yugisu-flux, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness of feature flag evaluation within the React SDK by modifying the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
attachHandlersAndResolveattachHandlersAndResolve (closes #1331)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly addresses a race condition by ensuring the Ready event listener is always attached in attachHandlersAndResolve, regardless of the client's initial status. This prevents components from failing to update when a new provider is set. The removal of status from the useEffect dependency array is a logical consequence of this change. The new test case effectively validates this fix by simulating the specific race condition. I have one minor suggestion to improve the clarity of the new test.
| resolveBooleanEvaluation() { | ||
| return { value: false }; | ||
| } | ||
| resolveNumberEvaluation() { | ||
| return { value: 42 }; | ||
| } | ||
| resolveObjectEvaluation<T>(_: string, __: T) { | ||
| return { value: {} as T }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While these changes could indeed improve readability, they will break the Provider interface requirement in the OpenFeature.setProvider call later on. These methods are kept as slim as possible so they don't really mess with the test's readability.
…HandlersAndResolve` Signed-off-by: Dmytrii Puzyr <dmytrii.puzyr@datadoghq.com>
67bf273 to
a61af23
Compare
lukas-reining
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me and I do not see real negative consequences.
Thanks for bringing up the issue and fixing it @yugisu-flux!
Let's wait for @toddbaert before merging.
| } | ||
| // Always register the Ready handler to catch provider initialization | ||
| // even if current status is already READY (e.g., from a NoOp provider) | ||
| client.addHandler(ProviderEvents.Ready, updateEvaluationDetailsCallback, { signal: controller.signal }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is okay as updateEvaluationDetailsCallback checks the flag details for equality.
So even if the provider renders as ready and the handler triggers, only one render should be done.
Or am I overlooking anything @toddbaert?
Motivation
This PR fixes #1331
Changes
attachHandlersAndResolveto always attach theProviderEvents.READYlistener to the client independently of the initial state.