Repository navigation
Compute client storage dependents once per hydrate - #7568
Conversation
hydrate_and_load passes the browser's client storage values through get_delta overrides after the snapshot. It marked them dirty with _mark_dirty, so their computed dependents were invalidated and evaluated a second time, although the snapshot had already sent them computed from the same values. Build that delta with only the dirty fields: build_delta skips invalidating and sending computed vars while _send_fields_only is set. The overrides still see the browser values once, and what they return still reaches browser storage. Fixes reflex-dev#7508
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a7213d24b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merging this PR will not alter performance
|
[Medium impact] The PR appears safe to merge; no actionable issues remain. SummaryThe PR avoids computing client-storage dependents again after sending the hydration snapshot.
The previous unused-set finding is fixed. The normal Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." · Reviewed by Greptile |
masenf
left a comment
There was a problem hiding this comment.
nice fix, thanks for simplifying
Fixes #7508. A smaller alternative to #7515.
Problem
hydrate_and_loadsends the snapshot first. Then it passes the browser's client storage values throughget_deltaoverrides again. It marked those values dirty with_mark_dirty. That invalidated their computed dependents, so each dependent was evaluated a second time. The snapshot had already sent them, computed from the same values. In reflex-local-auth, this runs theauthenticated_userdatabase query twice on every page load.Fix
The second pass now builds a delta that holds only the dirty fields. While
_send_fields_onlyis set,build_deltadoes not invalidate or send computed vars. The pass runs inside the handler, so the flag does not reach any other delta.The behavior stays the same as on
main:Testing
A new test,
test_hydrate_computes_client_storage_dependents_once, fails onmainand passes with the fix. It checks a cached dependent in the same state and a cached dependent in a sibling state. It also checks that an uncached var is not evaluated more often than in a hydrate without stored values.I also ran an example app in Chrome against
main, with stored values set. The app has a cached dependent, a sibling dependent, an uncached var, an override that rewrites a value, and an override that drops a key. Per reload:mainThe displayed values, the stored values and the backend values stay the same as on
main.The pass now sends its own delta, so a hydrate with stored values sends one more websocket message than on
main. This PR does not change that.