fix(server): diagnose node-pty startup failures #5280
main fromrefs/pull/5280/head·opened View on GitHubWhat changed#
- Render actionable node-pty native-load diagnostics from the CLI, set a non-zero exit code, and keep the adapter failure typed.
- Repair
spawn-helperpermissions on non-Windows hosts with retries after transient path/chmod failures, while skipping chmod for helpers executable by the current uid/gids. - Surface non-executable helpers as a structured error with
helperPathand the underlyingcause; stop shell fallback and publish the chmod remedy. - Add focused regressions for startup output, permission modes, nested causes, platform behavior, shell fallback, and terminal error events.
Why#
Broken native installs previously exited without an actionable diagnosis, and a non-executable spawn-helper made every shell candidate fail with a misleading generic error. The structured diagnosis preserves the original failure while making the remediation visible at the correct boundary.
Validation#
vp run --filter t3 typecheck- Targeted
vp lintandvp fmt --checkfor the seven touched files - Focused Vitest runs for
NodePtyAdapter.test.ts, the new CLI test, the new helper-error manager test, and the existing generic shell-fallback test
No resize handling or terminal-history sanitization changes are included.
Note
Diagnose node-pty spawn-helper failures with actionable stderr output#
- Adds
SpawnHelperNotExecutableErrorinPtyAdapter.tsto represent non-executable spawn-helper failures with a directchmodremediation message. NodePtyAdapternow detectsposix_spawnpfailures caused by a non-executable spawn-helper, wraps them asSpawnHelperNotExecutableError, and attemptschmod 0755on the helper path before spawning.NodePtyModuleLoadErrorgains adiagnosticgetter that returns a multi-line user-facing explanation with remediation steps, suitable for writing to stderr.reportStartupDefectinserver.tswrites any defect'sdiagnosticstring to stderr and setsprocess.exitCode = 1on startup failure.- Shell retry logic in
TerminalManageris short-circuited when the cause is a non-executable spawn-helper, and error events surface the specific chmod advisory instead of a generic message.
Note
Medium Risk Touches terminal spawn path and CLI exit behavior on startup failures; changes are localized to node-pty adapter and server CLI with strong test coverage, but terminal startup is user-critical.
Overview Improves node-pty failure handling so broken installs and bad spawn-helper permissions surface clear remediation instead of silent or misleading errors.
The CLI now hooks startup defects via reportStartupDefect: writes adapter diagnostic text to stderr, sets exit code 1, so native load failures (e.g. NodePtyModuleLoadError) are visible in headless serve runs.
On Unix, spawn-helper repair checks POSIX execute bits for the current uid/gids (not just any exec bit), skips chmod when already executable or on read-only stores, and maps posix_spawnp failures to SpawnHelperNotExecutableError with a chmod +x message. Terminal manager stops shell fallback for that case and publishes the structured error to terminal events.
Adds focused tests for CLI stderr output, permission modes, spawn failure classification, and manager retry behavior.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 8da75622b88a465a5fa7bfe34496e7793bbeefb3. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).closes #4924
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
Approvability#
Verdict: Needs human review
This PR introduces substantial new logic for error diagnosis: new error types, POSIX permission checking, process identity detection, and modified spawn failure handling paths. The scope of changes to terminal spawn behavior warrants human review despite being framed as diagnostics.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).StiensWout(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
85875bde-b501-42e8-86aa-7977fb861f20You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share