fix(client-runtime): preserve queries during connection handoff #8311
Closedtris203(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/8311/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- packages/client-runtime/src/state/runtime.ts line 546OutdatedResolvedby tris203(GitHub profile, opens in a new tab)@@ -529,4 +537,10 @@529537 switch (connectionState.phase) {530538 case "connected":531539 return Option.isSome(session)532- ? runInEnvironment(target.environmentId, options.execute(target.input))540+ ? runInEnvironment(target.environmentId, options.execute(target.input)).pipe(541+ // Session teardown and this atom's connection signal are542+ // delivered independently. If the request observes teardown543+ // first, keep it pending until the signal selects the544+ // reconnecting or terminal branch instead of flashing a545+ // transient unavailable failure.546+ waitForEnvironmentConnectionSignal,
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
maria-rcks closed this
maria-rcks reopened this
maria-rcks closed this
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
a686da94-46e0-4a02-b7c1-6848470b4977📥 Commits
Reviewing files that changed from the base of the PR and between 17f352f815d7821976622d18cd993504b9a4141d and 079abdb803efe54bb7c04a14781bbac53120bbb3.
📒 Files selected for processing (2)
packages/client-runtime/src/state/runtime.test.tspackages/client-runtime/src/state/runtime.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
📝 Walkthrough
Walkthrough#
Registry-owned supervisors now receive their configured enabled state during creation. Connected environment queries wait for a connection signal when session loss produces an unavailable error. Tests cover the connecting phase and query outcomes during session loss.
Changes#
Connection race handling
packages/client-runtime/src/connection/registry.ts,packages/client-runtime/src/connection/registry.test.tscreateServiceScopepassesentry.enabledtoEnvironmentSupervisor.makeand removes the explicit connection call. A test checks that a persisted environment reportsconnectingwhile session connection is in progress.packages/client-runtime/src/state/runtime.ts,packages/client-runtime/src/state/runtime.test.tsEnvironmentRpcUnavailableErroroccurs after the observed session is no longer current. Tests cover the session-loss race and verify that the error remains a failure when the session is still live.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Sequence Diagram(s)#
Suggested reviewers:
juliusmarmingeMerge Risk: ⚪ Minimal · up to
079abThe change prevents transient "environment unavailable" flashes during session replacement and registry startup. It also keeps failures visible when the session is still live. I found no concrete remaining risk that should block merging.
Architecture Summary#
Architecture risk: 🔵 Low · up to
079abThe change affects 1 system.
Changed systems:
packages/client-runtimeArchitecture concerns No architecture-level concerns identified.
Review details
Systems and components
Before / after behavior
connecting, and then releases the connection.createServiceScopenow initializes the supervisor’s desired state fromentry.enabled; previously it always initialized as undesired, then explicitly calledsupervisor.connectwhen the entry was enabled.if (entry.enabled) supervisor.connectbranch was removed.🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.