Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): stop npm 12 silently skipping node-pty builds in the pinned runtime #9380

Closednone23(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/9380/headopened View on GitHub

What Changed

The pinned runtime installer now stages a package.json that allows install scripts for node-pty and msgpackr-extract. npm 12 rejects --allow-scripts for project-scoped installs, so the manifest is the only place to grant this.

The __service-preflight that self-update runs against a staged runtime now also loads node-pty, so a runtime whose native binary is missing is reported as blocked with an actionable reason instead of being published.

npx t3 does not use the pinned runtime and is unaffected.

Why

npm 12 blocks dependency install scripts by default while still exiting successfully. The pinned runtime installer trusted that exit code, wrote its success sentinel without a pty.node binary, and could publish a runtime that crash-looped the background service on Linux.

Verified on Linux x64 with npm 12.0.2:

  • Before: the default install exited 0, warned that scripts were blocked, and produced no build/Release/pty.node.
  • After: the staged allowScripts manifest compiled build/Release/pty.node.
  • Passing --allow-scripts failed with EALLOWSCRIPTS.
  • With allow-scripts=<other-package> in a user-level ~/.npmrc, npm 12 refuses every project-scoped install with EALLOWSCRIPTS (exit 1), manifest or not. That case now fails loudly at the install step instead of crash-looping; removing the stale key from ~/.npmrc is the fix on such a machine.

Fixes #7475

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (not applicable)
  • I included a video for animation/interaction changes (not applicable)

Implemented by Fable 5.1 via Claude Code.


Note

Medium Risk Changes self-update/runtime install and preflight gating for native modules; incorrect behavior could block good installs or still allow broken runtimes, but scope is focused and covered by new tests.

Overview Addresses npm 12 silently succeeding on pinned runtime installs while skipping native dependency install scripts, which left runtimes without pty.node and could crash-loop the service on Linux.

The pinned runtime installer now writes a staged package.json before npm install with allowScripts enabled for node-pty and msgpackr-extract (project-scoped installs cannot use --allow-scripts, so the manifest is the grant path).

Service preflight is now async and imports node-pty as part of readiness checks; a missing native binary returns blocked with an actionable reason instead of publishing a broken runtime. The hidden __service-preflight CLI awaits that promise before printing JSON.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 41e004fabcd45e6e5bd0933e65f1711628a4e56b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix installPinnedRuntime to allow node-pty native build scripts in staged npm manifest

  • npm 12 silently skips native build scripts when the project manifest lacks an allowlist entry, so the pinned runtime installed without a working node-pty. The installer now writes a serialized manifest (PINNED_RUNTIME_PACKAGE_JSON) into the staging directory before running npm, with node-pty and msgpackr-extract in the native build allowlist.
  • runServicePreflight is now async and dynamically imports node-pty after the launcher protocol check. If the import fails, preflight returns a blocked result with the loader error and installation guidance instead of a ready result.
  • Behavioral Change: runServicePreflight now returns a Promise; callers in servicePreflight.ts and servicePreflight.test.ts are updated to await it. A manifest write failure now aborts installation via PinnedRuntimeInstallError.
Macroscope summarized 538ff23.

Summary by CodeRabbit

  • Bug Fixes
    • Improved pinned runtime installation so required native dependencies build correctly during setup.
    • Service preflight now verifies that the terminal dependency loads successfully before marking the service ready.
    • When the dependency cannot load, preflight reports a blocked status with diagnostic error details.
    • Updated command-line preflight handling to correctly await and display the resulting service status.
    • Improved setup diagnostics to help identify unavailable terminal functionality before service startup completes.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This focused server fix changes pinned-runtime installation and staged preflight behavior by enabling native build scripts and blocking runtimes that cannot load node-pty. A new line-level static-analysis suppression is also included, so human review is required.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      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: f1f90886-fc73-4b82-817f-5fc40ad4041f

      📥 Commits

      Reviewing files that changed from the base of the PR and between 0fe4c99ee6df4cbb7a9064d2d86ece65ecef5eb3 and 3c85914a8c7ea007fb2645c9aacfc55d73b7d513.

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

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


      📝 Walkthrough

      Walkthrough

      The change enables native build scripts in the pinned runtime and makes service preflight asynchronously validate node-pty, returning diagnostic blocked results when loading fails.

      Changes

      Native runtime and service preflight

      Layer / File(s)Summary
      Pinned runtime native script configuration
      apps/server/src/cloud/pinnedRuntime.ts, apps/server/src/cloud/pinnedRuntime.test.ts
      The installer writes a staging package.json with native dependency script permissions before npm runs. The test verifies the staged manifest.
      Asynchronous node-pty preflight validation
      apps/server/src/cloud/servicePreflight.ts, apps/server/src/cloud/servicePreflight.test.ts, apps/server/src/cli/servicePreflight.ts
      runServicePreflight now loads node-pty asynchronously and returns blocked diagnostics when loading fails. The CLI logs the resolved result, and tests cover successful and failed loading.

      Priority: ➖ Normal

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

      Severity of issue fixed: Medium

      Sequence Diagram(s)

      sequenceDiagram
        participant ServicePreflightCLI
        participant runServicePreflight
        participant NodePtyLoader
        ServicePreflightCLI->>runServicePreflight: invoke preflight
        runServicePreflight->>NodePtyLoader: load node-pty
        NodePtyLoader-->>runServicePreflight: resolve or reject
        runServicePreflight-->>ServicePreflightCLI: return ready or blocked result

      Merge Risk: ⚪ Minimal · up to 3c859

      The change stages native dependency script permissions and blocks service readiness when node-pty cannot load. No actionable merge-blocking risk is currently established.

      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly identifies the npm 12 install-script problem and the affected pinned runtime. It accurately summarizes the primary change.
      Description check✅ PassedThe description includes the required What Changed, Why, and Checklist sections. It explains the failure, the fix, validation results, and that UI-related items are not applicable.
      Linked Issues check✅ PassedThe changes address issue #7475 by enabling the required native install scripts in the staged runtime manifest and blocking publication when node-pty cannot load. The tests cover both manifest configu…
      Out of Scope Changes check✅ PassedThe installer, preflight, CLI, and test changes are directly related to the npm 12 native-build failure described in issue #7475. No unrelated code changes are identified.
      Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 5 files.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Comment `@coderabbitai help` to get the list of available commands.
    4. 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.

    5. Superseded by #11510 (self-contained release-archive runtimes only).

      The npm pinned-runtime installer this PR patches is gone — archives ship node-pty / msgpackr-extract prebuilt, so staging an allow-scripts package.json is no longer needed. Closing in favor of main.

    6. juliusmarminge closed this

Sign in to join this conversation.