fix(server): the service no longer crash-loops after t3 update crosses a launcher protocol #12629
ClosedMnigos(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/12629/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/cloud/serviceProtocol.ts line 196OutdatedResolvedby Mnigos(GitHub profile, opens in a new tab)@@ -179,3 +179,18 @@179179 }180180 }181181182+/** Reads the two-field document an install writes, stamped with an older183+ protocol. `t3 update` installs from the outgoing CLI, so a newer launcher184+ finds that CLI's protocol next to its own version. The protocol guards the185+ runtime layout, which the launcher checks itself before starting a child,186+ so the document is adopted; one carrying an update record belongs to an187+ older launcher's update flow and is not. */188+export function adoptOlderInstallState(value: string): ServiceState | undefined {189+ try {190+ const parsed: unknown = JSON.parse(value);191+ if (192+ !isRecord(parsed) ||193+ parsed.update !== undefined ||194+ typeof parsed.protocol !== "number" ||195+ !Number.isInteger(parsed.protocol) ||196+ parsed.protocol < 1 ||
juliusmarminge added labelsmacroscope-review
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Mnigos(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
c3f6dde5-d413-4e64-ae23-80797fcc6b64📥 Commits
Reviewing files that changed from the base of the PR and between 8abc60bd33cf9553a2766a4328134d9f918b5041 and d39aba2ea985675dd3872f4335ff56a41895eb38.
📒 Files selected for processing (1)
apps/server/src/cloud/serviceProtocol.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The service launcher adopts compatible older install-state protocols, rewrites them with the current protocol, and starts the active runtime. Tests cover legacy protocols, invalid states, malformed JSON, persistence, and runtime startup.
Changes#
Service state compatibility
apps/server/src/cloud/serviceProtocol.tsadoptOlderInstallState, which validates compatible install-state documents and normalizes their protocol.apps/server/src/serviceLauncher.ts,apps/server/src/serviceLauncher.test.tsreadServiceStatepersists adopted state before returning it. Tests cover protocols 1 and 2, runtime startup, rejected states, malformed JSON, and unchanged files after rejection.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~15 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
t3dotggMerge Risk: ⚪ Minimal · up to
d39abThe launcher migrates the compatible legacy install state before starting the service. No actionable merge blocker is established.
Security Architecture Review#
Security architecture risk: 🔵 Low · up to
d39abThe compatibility change retains version validation and runtime checks, with no demonstrated expansion of remote authority. A remaining concurrency risk is that startup normalization could overwrite a newer installation state if installation and launcher startup overlap.
Retained concerns
Security review details
Security Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#12627].adoptOlderInstallStateaccepts compatible protocol 1 and 2 documents without update records, rewrites them with the current protocol, and valida…#12627]. Production changes implement legacy service-state adoption and durable migration. Tests cover the migration and strict rejection behavior. No unrelated production beh…✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.