fix: ensure global vars load properly on first flow - #12538
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (49.60%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## release-1.9.0 #12538 +/- ##
=================================================
- Coverage 52.44% 52.33% -0.12%
=================================================
Files 2013 2013
Lines 182368 181691 -677
Branches 28433 25761 -2672
=================================================
- Hits 95646 95080 -566
+ Misses 85648 85536 -112
- Partials 1074 1075 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
* fix: Ensure global vars load properly on first flow * Add tests --------- Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com>
* fix: Ensure global vars load properly on first flow * Add tests --------- Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com>
This pull request addresses a race condition in the global variable loading logic for the
InputGlobalComponent. The changes ensure that values are not incorrectly cleared or reset while the global variables are still being fetched, which could previously result in references being wiped on initial load. The update introduces a guard using theisGlobalVariablesFetchedflag to synchronize state updates with the completion of the global variables query.Key improvements include:
Race Condition Fixes & Data Fetch Synchronization:
isGlobalVariablesFetchedflag from theuseGetGlobalVariableshook and passed it through to the relevant hooks and effects inInputGlobalComponentand its hooks. This ensures that state updates only occur after the global variables have finished loading, preventing premature clearing of values. [1] [2] [3] [4]isGlobalVariablesFetched, preventing race conditions during the first flow load. [1] [2]Code Cleanup:
useCallback) fromhooks.tsfor improved code clarity.These changes collectively make the component more robust against asynchronous data-fetching issues and improve maintainability.