fix(storage): defer binding updates until ensemble.storage.clear() completes#2231
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(storage): defer binding updates until ensemble.storage.clear() completes#2231cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
…pletes EnsembleStorage.clear() called clearPublicStorage() without awaiting; binding listeners re-evaluate expressions by reading GetStorage, so notifications could run while keys still existed and refresh the UI from stale values. Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a race in
EnsembleStorage.clear():StorageManager.clearPublicStorage()is asynchronous (eachGetStorage.removeis awaited in a loop), but storage binding listeners handleModelChangeEventby re-evaluating the full binding expression viadataContext.eval(), which reads the current value from GetStorage. Firing those dispatches immediately after starting the async clear meant listeners could still read non-null persisted values and repopulate bound widgets, so the UI could appear uncleared until an unrelated rebuild.Related Issue
None filed; same root cause as the investigation in #2227 (that PR was closed with no code landed).
Type of Change
What Has Changed
EnsembleStorage.clear()now usesunawaited(StorageManager().clearPublicStorage().whenComplete(...))soScreenController.dispatchStorageChangesruns only after the async clear finishes (or fails), preserving the synchronous invokable surface for scripts while fixing ordering for bindings.How to Test
modules/ensemble, runflutter test(includingtest/ensemble_storage_clear_test.dartandtest/storage_manager_test.dart).\${ensemble.storage.someKey}, callensemble.storage.clear()from an action, and confirm the bound UI reflects cleared storage without needing a second interaction or navigation.Screenshots / Videos
N/A
Checklist
flutter analyzeand addressed any new warningsflutter testand all tests passNote: The CI/automation image used here did not have the Flutter SDK on
PATH, soflutter analyze/flutter testwere not executed in this environment. Please run them locally perAGENTS.md.