Repository navigation
fix(process): await Swift frontend lifetime pipe - #7948
Merged
Merged
Conversation
Contributor
[Medium impact] The PR appears safe to merge within its stated compiler-compatibility limits. SummaryThe PR makes Darwin helper compilation wait for an extra inherited pipe before removing its temporary root.
DiagramsequenceDiagram
participant Reader as Darwin helper owner
participant Command as execFileOutput
participant Driver as Compiler driver
participant Writer as Detached frontend
Reader->>Command: Compile with lifetimePipe
Command->>Driver: Spawn with fd 3
Driver->>Writer: Inherit fd 3
Reader->>Command: Cancel
Command->>Driver: SIGINT
Driver-->>Command: Exit and close standard streams
Writer->>Writer: Finish object writes
Writer-->>Command: Close inherited fd 3
Command-->>Reader: Settle command
Reader->>Reader: Remove temporary root
Reviews (1) · Last reviewed commit: "fix(process): await Swift frontend lifet..." · Reviewed by Greptile |
morluto
marked this pull request as ready for review
October 28, 2026 22:57
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related to #5502. Cancelling the Darwin ownership helper compile could remove its temporary root while a detached Swift frontend was still writing, leaving object files after normal server exit. The compiler command now retains and drains an extra inherited lifetime pipe before removing that root.
Problem and expected behavior
On current main, an isolated MCP cancellation sweep left two helper roots, each containing 256,904 bytes of Swift object files, after normal server exit and both 1 s and 2.5 s samples. A real compiler probe observed
xcrun swiftcand stdout/stderr close around 45 ms while the descriptor retained by its frontend workers closed around 269 ms. Cleanup must wait for the writer, preserve cancellation and retain failed cleanup ownership.Change and scope
execFileOutputoptionally adds a drained inherited pipe for stoppable commands; only Darwin helper compilation opts in. Its closure makes settlement wait for copies inherited by the observed Swift frontend jobs. Cancellation, timeout and shared waiter policy remain unchanged. The fixture now models a detached writer whose standard streams close while it survives the interrupted driver, rather than killing the writer on SIGINT.Contract and boundary impact
Expected effects:
Evidence and regression coverage
lsofconfirmed both actual Swift frontend workers inherited fd 3 on this host. In 24 xcrun and 18 direct swiftc short-cancellation trials, removal after descriptor closure did not lead to recreation during 350 ms. Eight link-stage interruption probes also saw sampled descendants absent at close and no recreation during 350 ms.ldprocesses did not expose fd 3. The issue's original Apple Swift 6.4 / Node 26 combination, other compiler versions and later writes beyond these observations remain unverified. This PR does not claim that broader proof or close [Bug] Cancelled JavaScript analysis can still leave the macOS helper's temporary folder after #1194 #5502 automatically.Validation performed
npm run test:focused -- tests/boundary/process/darwinProcessRunTokenReader.test.ts— 35 passed.npm run test:local -- src/process/ExecFileOutput.test.ts— 44 passed.npm run check:fastandgit diff --check— passed.Compatibility, safety, and release
Cancellation may wait for Swift frontend-held descriptor closure before removing the owned root. No schema change. Cleanup completion for processes that do not inherit the descriptor remains unproven.
Author readiness
Human owner: @morluto
Before merge
type(scope): outcome.