Repository navigation
fix(process): report the Swift compiler outcome with bounded diagnostics - #1999
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85910838be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| failure?.code ?? | ||
| (cause instanceof Error && "code" in cause | ||
| ? String(cause.code) |
There was a problem hiding this comment.
Preserve null exit codes for signaled compilers
When swiftc terminates because of an unexpected signal (for example, SIGSEGV), Node's execFile error has code: null and a populated signal. This ?? treats that meaningful null as absent and falls through to String(cause.code), producing the string "null"; consequently the signal branch in compilerOutcome is never reached and users see compiler result: null instead of the actual signal. Preserve failure.code whenever a parsed failure exists so the new error retains the meaningful failure reason.
AGENTS.md reference: AGENTS.md:L23-L23
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — fixed in 1ccc26e: the fallback now applies only when no parsed failure exists, so a signaled compiler's null exit code reaches compilerOutcome and reports stopped by signal SIGSEGV. Added a regression test that kills a fake compiler with SIGSEGV and asserts that exact message.
|
Thanks, @jimpablo, for making Swift helper failures report the actual compiler outcome and a bounded diagnostic excerpt. Covering exit, timeout, signal, and truncation cases should make these macOS setup failures much easier to diagnose without letting compiler output grow without bound. Welcome to REA! |
|
Thank you! The existing |
Summary
Fixes #1993. The Darwin process-ownership helper compilation surfaced only
cause.codeandcause.messagefrom the rejected compile. At the 60 s deadline that producedcompiler result: ETIMEDOUT): Command timed out after 60000 ms: /usr/bin/xcrunwith the compiler's captured stderr discarded, so a broken Swift/SDK pairing was indistinguishable from a genuinely slow compile — the exact report in #1993.Problem and expected behavior
xcrun swiftcprints SDK-mismatch diagnostics and stops responding; the helper failure reports only the generic timeout, with no exit code and no diagnostics.execFileOutputerror already carriesstdout/stderr, and the reader dropped them.exit code N,timed out after N ms, orstopped by signal S— followed by a bounded stderr excerpt (512 characters, truncation marked), or an explicitno compiler diagnostics were capturedwhen nothing was captured. Toolchain breakage is now distinguishable from a slow compile in both shapes.Change and scope
src/process/DarwinProcessRunTokenReader.ts: the compilecatchnow reads the failure through the existingexecFileOutputFailureextractor.compilerOutcomenames the outcome without implying an exit code a timeout lacks;compilerDiagnosticsbounds the excerpt at 512 characters (following thestderr_excerptprecedent inAdbConfiguration/ApktoolConfiguration) and marks truncation, including theERR_CHILD_PROCESS_STDIO_MAXBUFFERcase.COMPILER_TIMEOUT_MSreplaces the inline60_000, and acompileTimeoutMsfactory option lets verification exercise the deadline in milliseconds; the production default is unchanged.NativeUiHelperRuntimecompiles a sibling Swift helper with the same shape; it is left unchanged here and can follow separately with its own report.Contract and boundary impact
src/process/DarwinProcessRunTokenReader.ts, beforenormalizeCaptureFailurewraps the message.Evidence and regression coverage
Tests added or updated in
tests/boundary/process/darwinProcessRunTokenReader.test.ts: the fast-failure case now asserts the exact message…(compiler result: exit code 1): module cache is not writable; a new deadline case runs a compiler that prints an SDK-style diagnostic and then stops responding, and asserts…(compiler result: timed out after 500 ms): <diagnostic>; a new bound case asserts a 600-character diagnostic is cut at 512 characters with an explicit truncation marker.Base reproduction: with the source change stashed, the exact-message assertion fails on
f28f33828— the base message is Node'sCommand failed: …text and the captured stderr never reaches the message.Real coverage: the whole lane ran on macOS 27 arm64, Node 24.18.0 — 21 passed, including the unmodified real-Darwin tests (parser probe, ownership keys, executable padding).
Remaining proof gaps: the reporter's mismatched-CLT hang itself was not reproduced (this host has a healthy toolchain); failure shapes are exercised with fake compilers, which is what the lane already uses for this boundary.
Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run test:focused -- tests/boundary/process/darwinProcessRunTokenReader.test.ts— 21 passednpm run check:fast— green (typecheck, lint)npm run verify:test-discovery— 884 files discovered exactly oncenpm run check— green (typecheck, lint, format, knip, metadata, architecture guards)git stashof the source change — new assertion fails on unmodified mainCompatibility, safety, and release
Review checklist
type(scope): outcome.