Repository navigation
fix(desktop): invalidate stale runtimes before profile reopen - #94927
Tomenatore wants to merge 1 commit into
Conversation
Remember secondary scopes across renderer pool pruning and clear their process-local runtime bindings before a later socket can publish open. This prevents eager session RPCs from racing a respawned profile backend with an ID minted by the previous process.
Moving the invalidation from A few observations:
Well-scoped fix with a genuinely useful ordering assertion in the test. |
|
Merged via #95080 at 682a34a — your commit was cherry-picked into the consolidated salvage PR with authorship preserved, so this work carries your name in git history. Thanks for invalidating stale runtimes before profile reopen — that stale-runtime window was a subtle one to spot. Closing this original PR now that the consolidated branch has landed on main. Thanks for contributing to the desktop multi-gateway campaign (tracker: #94724). |
Summary
openProblem
A profile backend can be evicted after its renderer-side
Secondaryentry is pruned while the renderer still holds that backend generation's runtime ID. The next profile action creates a freshSecondary, respawns/reopens the backend, and can immediately issue a session-scoped RPC with the old process-local ID. The new backend rejects it assession not found/no active session; reloading the window happens to recover only because it clears the renderer bindings.The existing cleanup ran after
reconnectSecondary(). It did not cover a directopenSecondary()caused by the next routed user action, and post-connect cleanup also left a race in which eager route/submit work could observeopenfirst.This is complementary to #94656: that PR improves owner continuity and foreground retention; this change covers the backend-generation boundary when a secondary was nevertheless disposed or restarted.
Approach
Verification
upstream/mainwith zero runtime-invalidation calls.npx vitest run --project uion six affected gateway/session files: 102 passed.npm run typecheck: passed.--max-warnings 0: passed.npm run build: passed, including renderer, Electron main/preload bundles, and native dependency staging.npm run test:ui: 5,718 passed / 12 failed on this Windows/de-DE host. Four locale-sensitive assertions reproduce identically on an unchangedupstream/mainworktree; the remaining full-load timeouts passed when the same baseline files were rerun in isolation. No changed-file or affected gateway/session test failed.Risk
Initial secondary opens are unchanged. Reopens add one local dynamic-import microtask before transport publication and conservatively re-resume bindings for only the reconnected scope. If UI-state reconciliation itself throws, the already-open transport remains successful as before.
Related to #93937, #94828, and #94872.