Skip to content

refactor(process): read execFile's abort through the signal owner - #11023

Closed
morluto wants to merge 1 commit into
refactor/hopper-errors-provider-ownedfrom
refactor/exec-file-output-abort-of
Closed

morluto wants to merge 1 commit into
refactor/hopper-errors-provider-ownedfrom
refactor/exec-file-output-abort-of

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

execFileOutput's non-stoppable path (execFile with the caller's signal) recognised execFile's cancellation by error.name === "AbortError" && error.code === "ABORT_ERR". It now uses the signal owner, isAbortOf(error, signal), and builds ExecFileOutputCancelledError from signal.reason. This was the last AbortError name comparison counted by the abort-error-name guard in src/process/. Its baseline entry is removed.

Stacked on #10964, which owns the guard and its baseline. This is one of the remaining AbortError name checks listed in W5. It is W4-adjacent, so it is kept to the one condition. Refs #5808.

Problem and expected behavior

execFile callback error Before After
execFile's abort for the caller's signal (ABORT_ERR, cause = caller's reason) ExecFileOutputCancelledError(error.cause) ExecFileOutputCancelledError(signal.reason): the same reason
An ABORT_ERR whose cause is not the caller's reason, or with no caller signal Reported as a cancellation Reported as the error itself

The second row is not reachable through real execFile: it raises ABORT_ERR only for the signal it was given. No test can produce it without replacing execFile, so this PR adds no new case. Behaviour is unchanged for every reachable outcome, and the existing exact-reason cases cover it (null, NaN, a string and an Error reason).

Change and scope

  • One condition in src/process/ExecFileOutput.ts.
  • scripts/verify/architecture-guard-baselines.json loses abort-error-name's src/process/ExecFileOutput.ts entry.
  • Not included: the stoppable path (startStoppableCommand), which owns its abort through its own listener and has no name check, and any other W4 finalization behaviour.

Contract and boundary impact

None.

Evidence and regression coverage

src/process/ExecFileOutput.test.ts covers the caller's own abort, with exact reasons, on both the pre-aborted and running paths.

Validation performed

  • npm run test:local -- src/process/ExecFileOutput.test.ts: 50 passed.
  • node scripts/verify/architecture-guards.mjs --shrink-baselines, then the guards: pass. npx tsc --noEmit -p tsconfig.json: clean. The pre-push check:fast passed.

Compatibility, safety, and release

No breaking change.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T10:23:19.001538Z bf4cd9d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf4cd9d684

ℹ️ 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".

Comment thread src/process/ExecFileOutput.ts Resolved
@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5 Tier: plus

[Low impact] The change is limited to cancellation matching in a shared process helper.

The PR should not merge until a late abort(null) stops changing successful commands into cancellations.

Fix All in CodexFindings

  1. P1 Successful commands become cancellations ▶
Fix with agent prompt
### Issue 1
src/process/ExecFileOutput.ts:undefined-246
`isAbortOf` accepts the reason itself, so `isAbortOf(null, signal)` returns true after `abort(null)`. But `null` here means the command succeeded.

When a command exits successfully while a descendant keeps its output pipe open, the caller can abort before the callback runs. Node still returns success, but this code changes it into `ExecFileOutputCancelledError`. The same timing with a string reason still succeeds. This was reproduced on Node 24.22.3.

Require `error !== null` before calling `isAbortOf`, and cover this late-abort case.

```suggestion
              error !== null && isAbortOf(error, signal)
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Routes execFile cancellation through isAbortOf and builds ExecFileOutputCancelledError from signal.reason.

  • The non-stoppable execFile path only treats its caller’s abort as cancellation.

Reviews (2) · Last reviewed commit: "refactor(process): read execFile's abort..." · Reviewed by Greptile

Comment thread src/process/ExecFileOutput.ts Resolved
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Superseded: #10906 (now in #10964) already reads execFile's abort as error !== null && isAbortOf(error, signal), with the late-abort regression test, and removed this file's abort-error-name baseline entry. This PR adds nothing beyond that and should be closed by the maintainer. I am not closing it myself.

@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Closing as superseded: #10906 already moved ExecFileOutput's abort check onto the shared signal owner, including the error !== null case both reviewers raised here. Nothing in this branch is still needed.

@morluto morluto closed this Nov 15, 2026
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant