fix(islands): ignore inactive session messages#10330
Open
peter-gy wants to merge 2 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Architecture diagram
sequenceDiagram
participant Worker as Pyodide Worker
participant Bridge as IslandsPyodideBridge
participant Store as Jotai Store
participant UI as React UI Components
Note over Worker,UI: Active session flow
Bridge->>Bridge: startSession(request)
Bridge->>Bridge: activeSessionGenerations.add(generation)
Bridge->>Store: Set islandsPendingInitialRunsAtom
Bridge->>Worker: proxy.request.startSession(request)
Worker-->>Bridge: session ready
loop Kernel messages
Worker->>Bridge: "kernelMessage" event
alt activeSessionGenerations.has(sessionGeneration)
Bridge->>Bridge: Forward to messageConsumer
Bridge->>UI: Apply cell/UI updates
else Session inactive
Bridge->>Bridge: Ignore message
end
end
Note over Worker,UI: Session replacement flow
Bridge->>Bridge: initializeApps()
Bridge->>Bridge: activeSessionGenerations.clear()
Bridge->>Bridge: nextSessionGeneration++
Bridge->>Bridge: startSession(request)
Bridge->>Bridge: activeSessionGenerations.add(generation)
alt Replaces previous single app
Bridge->>Store: Reset notebookAtom
end
Bridge->>Worker: proxy.request.startSession(request)
Note over Worker,Bridge: Asynchronous worker call in flight
Worker->>Bridge: "kernelMessage" (old generation)
alt Generation not in activeSessionGenerations
Bridge->>Bridge: Drop message
end
Worker-->>Bridge: session ready
Bridge->>Bridge: sessionReady.resolve()
Note over Worker,UI: Session stop flow
UI->>Bridge: stopSession()
Bridge->>Bridge: activeSessionGenerations.delete(generation)
Bridge->>Worker: proxy.request.stopSession(request)
Note over Worker,Bridge: Asynchronous worker call in flight
Worker->>Bridge: "kernelMessage" (stopped generation)
alt Generation not in activeSessionGenerations
Bridge->>Bridge: Ignore message
end
alt Error during session start
Bridge->>Bridge: activeSessionGenerations.delete(generation)
Bridge->>Bridge: Revert session to previous
Bridge->>Store: Restore previous state
end
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
peter-gy
marked this pull request as ready for review
July 25, 2026 18:51
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.
Follow up to #10207.
Drops kernel messages after their session yields ownership of the shared islands frontend.
Retained navigation reuses one frontend store across app sessions. Messages already in transit from the outgoing session could otherwise apply cell or UI updates to the incoming document when cell IDs overlap.
The bridge now tracks accepted session generations. Replacement and teardown revoke the outgoing generation before their asynchronous worker calls begin. A failed replacement restores ownership to the previous session. Multi-app documents retain every generation started for the current document.