fix(sse): rotate workspace streams without gaps - #7061
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryThe PR bounds workspace SSE lifetimes while using make-before-break client rotation to preserve event delivery and reconcile caches after genuine reconnect gaps.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/events/rotating-event-source.ts | Introduces rotation-aware EventSource ownership, make-before-break replacement, reconnect classification, and complete disposal. |
| apps/sim/lib/events/sse-endpoint.ts | Replaces hard expiration with announced rotation and a grace period while making setup and teardown failure-safe. |
| apps/sim/hooks/queries/mcp.ts | Migrates MCP event subscriptions to the rotating connection and reconciles queries after genuine reconnects. |
| apps/sim/hooks/use-mothership-chat-events.ts | Migrates mothership chat events to rotation-aware subscriptions while preserving cache reconciliation behavior. |
| apps/sim/lib/events/rotating-event-source.test.ts | Covers seamless replacement, reconnect classification, disposal during rotation, and replacement-construction failure. |
| apps/sim/lib/events/sse-endpoint.test.ts | Covers rotation grace behavior and failure-safe subscription setup and teardown. |
Sequence Diagram
sequenceDiagram
participant Client
participant Old as Current SSE stream
participant Server
participant New as Replacement SSE stream
Server->>Old: rotate event
Old->>Client: rotation requested
Client->>New: open replacement connection
Note over Old,New: Current stream remains active
New-->>Client: connection opened
Client->>Old: close current connection
Client->>New: promote replacement
alt Current stream dropped before replacement opened
Client->>Client: classify as reconnect
Client->>Client: reconcile affected caches
else Seamless replacement
Client->>Client: classify as rotation
end
Reviews (2): Last reviewed commit: "test(sse): cover delivery across rotatio..." | Re-trigger Greptile
There was a problem hiding this comment.
1 issue found across 7 files
Confidence score: 4/5
apps/sim/hooks/queries/mcp.tscan leave the legacy global connection map undiscovered during refresh, causing the hook to open a second workspace SSE stream; preserve or migrate the legacy key and close any stale connection.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/hooks/queries/mcp.ts">
<violation number="1" location="apps/sim/hooks/queries/mcp.ts:546">
P2: During a refresh from the previous implementation, this new key leaves the old global connection map undiscovered, so the hook can open a second workspace SSE stream. Preserve or migrate the legacy key, and close any legacy entries that cannot be reused.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Collaborator
Author
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.
Summary
Type of Change
Testing
bun run --cwd apps/sim test -- lib/events/sse-endpoint.test.ts lib/events/rotating-event-source.test.ts hooks/use-mothership-chat-events.test.ts hooks/queries/mcp.test.tsxbun run type-checkbun run lintbun run apps/sim/scripts/check-block-registry.ts origin/stagingbun run check:auditsChecklist