Files
reverse-engineering-anything/tests/boundary/process
IvenKooandmorluto ec17f39e82 fix(process): keep the Darwin helper exit cleanup from crashing the host (#11714)
fix(process): keep the Darwin helper's exit cleanup from crashing the host

When the macOS ownership helper root cannot be removed while the process
exits — descriptor exhaustion is the recorded case — `cleanupAtExit` let
`rmSync` throw from a `process.once("exit")` listener. Node reports that as
an uncaught error, so a successful command exits 1 and prints a stack for a
directory nobody can retry.

Remove the root best-effort at exit and name the retained root once through a
guarded synchronous write: Node cannot drain a queued stderr chunk from an
exit listener, so the warning uses `writeSync(2, ...)` and swallows a failed
report. The root's normal cleanup path, its retained-cleanup error and every
caller's classification are unchanged; only the exit-time failure stops
changing the exit status.

Verified: `src/process/DarwinHelperExitCleanup.test.ts` asserts the root is
gone after a successful removal with no report, and that a root the process
cannot remove is retained, named once, and does not throw (2 tests). The
permission case is skipped for root and Windows, where permissions do not
prevent removal. `check:fast` passes.

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-18 11:18:57 -05:00
..