Repository navigation
fix(terminal): guard dropInheritedNiceBoost to Linux in PTY spawn paths - #51064
Conversation
An older process-host left behind by a partial update does not export dropInheritedNiceBoost, so calling it unconditionally failed every PTY spawn on Windows and macOS. The helper is a no-op off Linux anyway, so only call it there. Refs #51055
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
ELI5
On Windows (and macOS) Orca could fail to open any terminal after an update, with
dropInheritedNiceBoost is not a function. That helper only does anything on Linux, so Orca now only calls it on Linux and the terminal opens again everywhere else.What Changed
spawnNativeDaemonPtyin the daemon and the local PTY runtime spawn) calleddropInheritedNiceBoost(pid)on every platform right afterpty.spawn. If the@orca/process-hostmodule in the install was older and lacked that export (seen after a partial 1.4.280 update), the call threw, so the shell spawn failed and the daemon reported "Daemon failed to spawn shell".process.platform === 'linux'before calling the helper. On Windows and macOS the call is skipped, so a stale process-host can no longer break PTY spawn there. Linux behaviour is unchanged.Why
dropInheritedNiceBoostalready returns immediately when the platform is not Linux, so skipping the call off Linux changes no behaviour. It just removes the dependency on that export from the spawn path on the platforms where the crash was reported. This is a partial fix: it does not address how a partial update can leave a mismatched process-host behind, and a Linux install in the same mismatched state could still hit the error.Linked Issue
Refs #51055
Visual Proof
N/A. No UI change. The fix removes a thrown error in the PTY spawn path, and the code change only affects which platforms make one helper call.
Testing
Repro (from the issue): Windows 1.4.280, opening a terminal fails with
(0 , ce.dropInheritedNiceBoost) is not a function, raised from the unconditional call afterpty.spawn.Verification: the off-Linux path no longer calls the import at all, so a missing export cannot throw there.
vitest run src/main/daemon/pty-subprocess/native-pty-spawn.test.tspasses. CI static gates (anti-slop oxlint, code-quality native-plugin oxlint, ast-grep, changed-code quality), oxlint and oxfmt are clean on both touched files.Platforms: macOS (unit tests and static gates). Not manually tested on Windows.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
No test was added. The behaviour change is a single platform guard around a helper that was already a no-op off Linux.
Performance
None, because this adds one
process.platformstring comparison per PTY spawn, which is not a hot path. A micro-benchmark puts it at about 10 ns per spawn (old 8.4 ns, new 10.4 ns), against a PTY spawn that takes milliseconds. There is no new I/O, subprocess work, polling or per-item fan-out.Risk
Level: Low
Linux still makes the same call. On Windows and macOS the helper was already a no-op, so skipping it changes nothing except that a missing export can no longer throw. To back it out, revert this commit.
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Reported by @lengocanh2005it
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)