Skip to content

fix: deliver linked state updates to all clients - #6934

Open
benedikt-bartscher wants to merge 4 commits into
reflex-dev:mainfrom
benedikt-bartscher:shared-state-redis-fix
Open

fix: deliver linked state updates to all clients#6934
benedikt-bartscher wants to merge 4 commits into
reflex-dev:mainfrom
benedikt-bartscher:shared-state-redis-fix

Conversation

@benedikt-bartscher

@benedikt-bartscher benedikt-bartscher commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review in cubic

@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a token-manager connectivity abstraction and refreshes Redis-owned socket records so shared-state updates can reach linked clients on other backend instances.

  • Adds cross-instance connection checks and Redis socket-record cache refresh.
  • Moves linked-client filtering into asynchronous fan-out tasks.
  • Adds local, remote, stale-record, moved-owner, and Redis-error tests.

Confidence Score: 4/5

The PR is not yet safe to merge because linked updates can still be sent to a disconnected SID while local disconnect cleanup is pending.

A locally owned cached socket record is accepted without refreshing ownership, while disconnect cleanup runs asynchronously and update delivery uses that same cached SID, leaving the previously reported dropped-update race reachable.

Files Needing Attention: reflex/utils/token_manager.py, reflex/app.py

Important Files Changed

Filename Overview
reflex/istate/shared.py Shared-state fan-out now checks token connectivity asynchronously before modifying linked client state; the previously reported pending-disconnect race remains.
reflex/utils/token_manager.py Adds a common connectivity API and Redis ownership refresh, but locally cached ownership is still trusted during asynchronous disconnect cleanup.
tests/units/istate/test_shared.py Adds coverage for local filtering and cross-instance Redis fan-out.
tests/units/utils/test_token_manager.py Adds focused coverage for local, stale foreign, moved foreign, and Redis-error connection checks.
news/6934.bugfix.md Documents the intended cross-worker shared-state delivery fix.

Reviews (3): Last reviewed commit: "cubic" | Re-trigger Greptile

Comment thread reflex/istate/shared.py Outdated
Comment thread reflex/istate/shared.py Outdated
Comment thread reflex/istate/shared.py
@codspeed-hq

codspeed-hq Bot commented Aug 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing benedikt-bartscher:shared-state-redis-fix (b643ed8) with main (d86f167)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@benedikt-bartscher
benedikt-bartscher marked this pull request as ready for review August 24, 2026 10:31
@benedikt-bartscher
benedikt-bartscher requested a review from a team as a code owner August 24, 2026 10:31
Comment thread reflex/utils/token_manager.py

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread reflex/utils/token_manager.py Outdated
Comment thread tests/units/utils/test_token_manager.py
Comment thread reflex/utils/token_manager.py Outdated
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.

1 participant