Skip to content

fix(server): build native dependencies before activating updates - #10687

Closed
flamboh wants to merge 1 commit into
pingdotgg:mainfrom
flamboh:t3code/investigate-server-update-fix
Closed

flamboh wants to merge 1 commit into
pingdotgg:mainfrom
flamboh:t3code/investigate-server-update-fix

Conversation

@flamboh

@flamboh flamboh commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Note

🤖 GPT-6 on behalf of Oliver

ELI5

Check that an update's terminal dependency works before switching to it.

Problem

npm 12 can exit successfully while skipping unapproved native builds. T3 then marks the runtime complete, but the new server fails to start because node-pty is missing its native binary.

Fix

Write staging-local build approvals for node-pty and msgpackr-extract. Load the candidate's node-pty with the service's Node executable before publishing or reusing the runtime. This covers local service installation and remote updates, preserving the running service on failure.

Validation: 54 focused tests, targeted lint, and server typecheck pass. Isolated npm 12 fixtures confirmed approved scripts run while unrelated scripts stay blocked; npm 11 accepts the manifest. Independent review found no actionable issues.

UI Changes

Before: no visual changes.

After: no visual changes.

Made with GPT-6 in Codex.

Note

Probe node-pty with host Node executable before activating pinned runtime updates

  • Pinned-runtime installation now requires the candidate runtime to successfully load node-pty via the host Node execPath before the completion sentinel is written or the staged directory is published; npm installs also receive a project manifest granting build approval for node-pty and msgpackr-extract.
  • bootService.ts and selfUpdate.ts pass the host executable path into ensurePinnedRuntimeInstalled so the probe runs before server preflight and launcher handoff.
  • Tests across bootService.test.ts, pinnedRuntime.test.ts, and selfUpdate.test.ts cover the probe success and failure paths, including verification that a failed probe leaves the running service untouched.
  • Behavioral Change: cached and newly staged runtimes that fail the node-pty load probe now produce a PinnedRuntimeInstallError and leave no final installation, whereas previously a runtime with missing or unusable native binaries could be accepted.

Macroscope summarized 49f6449.

Summary by CodeRabbit

  • Bug Fixes
    • Pinned runtime installations now verify that required native modules load successfully before completing.
    • Runtime updates and installations report a clear failure when native module loading is unavailable.
    • Reinstall attempts preserve the currently running service when validation fails, avoiding unnecessary stops or restarts.
    • Improved compatibility with environments requiring explicit approval for native module builds.
    • Failed runtime preparation no longer interrupts an existing service unnecessarily.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 8, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 49f6449

Macroscope's review found this PR approvable — This is a contained server update bug fix: native dependencies are approved and verified before a runtime is published or handed off, while failed validation leaves the existing service untouched. The affected production logic is localized and supported by tests for both successful and failed native-module loading.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 447fd9a5-0ceb-4b8a-bf41-7db259456f4a

📥 Commits

Reviewing files that changed from the base of the PR and between e16b8b0 and de5b70d.

📒 Files selected for processing (6)
  • apps/server/src/cloud/bootService.test.ts
  • apps/server/src/cloud/bootService.ts
  • apps/server/src/cloud/pinnedRuntime.test.ts
  • apps/server/src/cloud/pinnedRuntime.ts
  • apps/server/src/cloud/selfUpdate.test.ts
  • apps/server/src/cloud/selfUpdate.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • apps/server/src/cloud/selfUpdate.ts
  • apps/server/src/cloud/pinnedRuntime.ts
  • apps/server/src/cloud/bootService.ts
  • apps/server/src/cloud/pinnedRuntime.test.ts
  • apps/server/src/cloud/bootService.test.ts
  • apps/server/src/cloud/selfUpdate.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The pinned runtime installation now approves required native builds and verifies that node-pty loads with the host Node executable. Boot installation and self-update pass this executable path, with tests covering successful, failed, cached, staged, and update scenarios.

Changes

Pinned runtime validation

Layer / File(s) Summary
Runtime validation and native build approvals
apps/server/src/cloud/pinnedRuntime.ts, apps/server/src/cloud/pinnedRuntime.test.ts
ensurePinnedRuntimeInstalled now receives execPath, writes npm native build approvals, and validates node-pty before accepting a runtime. Tests cover native module availability, manifest contents, and updated command sequences.
Boot and self-update integration
apps/server/src/cloud/bootService.ts, apps/server/src/cloud/selfUpdate.ts, apps/server/src/cloud/bootService.test.ts, apps/server/src/cloud/selfUpdate.test.ts
Boot installation and self-update pass the host executable path. Tests verify failed native module loading preserves the active runtime and prevents update handoff.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to de5b7

The runtime activation flow now validates required native dependencies before replacing or reusing a server runtime, with no current merge-blocking risk identified.

Sequence Diagram(s)

sequenceDiagram
  participant BootOrUpdate
  participant ensurePinnedRuntimeInstalled
  participant validatePinnedRuntime
  participant HostNode
  participant node-pty
  BootOrUpdate->>ensurePinnedRuntimeInstalled: provide host execPath
  ensurePinnedRuntimeInstalled->>validatePinnedRuntime: validate staged or cached runtime
  validatePinnedRuntime->>HostNode: require node-pty with CommonJS check
  HostNode->>node-pty: load native module
  node-pty-->>HostNode: success or load error
  validatePinnedRuntime-->>ensurePinnedRuntimeInstalled: validation result
  ensurePinnedRuntimeInstalled-->>BootOrUpdate: prepared runtime or error
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: building native dependencies before activating server updates.
Description check ✅ Passed The description explains the problem, the fix, validation, and the absence of UI changes. It does not use the template's exact "What Changed" and "Why" headings, and it omits the checklist, but it pro…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 6…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@flamboh
flamboh force-pushed the t3code/investigate-server-update-fix branch from 49f6449 to de5b70d Compare September 9, 2026 20:52
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

flamboh commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 GPT-6 on behalf of Oliver

Closing as superseded by #11510, which is already in both main and t3code/codex-turn-mapping.

This PR adds npm build approvals and a Node-based node-pty probe to the old npm-managed pinned runtime. Pinned runtimes now come exclusively from release archives, with checksum verification and staged executable preflight before activation. The npm install path this change fixes no longer exists. Retargeting it would restore obsolete updater assumptions.

@flamboh flamboh closed this Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant