Fix SSE reconnect stability and add configurable query cache retention#2194
Merged
Conversation
In load-balanced deployments (e.g. Azure Container Apps) the SSE GET and the subscribe POST can land on different backend instances. The server-side connection registry is in-process, so the subscribe returns 404 when it hits an instance that does not hold the SSE connection. Previously a single 404 immediately tore down and re-opened the EventSource, causing a reconnect cascade that took 2-3 cycles before the load balancer happened to route both requests to the same instance. Now sendSubscribe retries up to 3 times with increasing back-off delays (200 ms, 400 ms, 600 ms) before falling back to a full reconnect. With round-robin load balancing across N instances, at most N-1 retries are needed — covering deployments with up to 4 replicas without ever tearing down the SSE connection unnecessarily. A captured connectionId guard ensures stale retries are silently dropped if a reconnect fires from another cause in the meantime. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two related improvements to QueryInstanceCache:
1. setLastResult now compares the incoming data (JSON) and isSuccess against
the previously cached result before broadcasting to listeners. When an SSE
reconnect causes the server to re-send an identical dataset the comparison
short-circuits and React components are never asked to re-render — preserving
transient UI state such as row selections, open panels, and scroll position.
2. The QueryInstanceCache constructor now accepts a retentionMs value (default
30 000 ms) instead of the unused development boolean. After the last
subscriber unmounts the cache entry and its subscription are kept alive for
this window before being evicted. Users navigating back to a page within
the window see cached data immediately; memory is still reclaimed once the
timer expires.
Exposed through Globals.queryCacheRetentionMs and the new
<Arc queryCacheRetentionMs={...} /> prop so applications can tune the value
without modifying framework internals.
The now-meaningless *_in_development_mode and *_outside_development_mode spec
files are removed; their coverage is merged into the_only_subscriber.ts. New
specs verify the before/after retention window behavior.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add documentation for the new queryCacheRetentionMs setting across all three relevant pages: the Arc component reference, the React queries configuration guide, and the core Globals configuration reference. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Fixed
Added
queryCacheRetentionMsprop on<Arc />andGlobals.queryCacheRetentionMs— configures how long the query cache retains an entry after the last subscriber unmounts before evicting the subscription. Defaults to 30 seconds, allowing users to navigate back to a page without a loading flash. Set to0to restore immediate eviction.