Skip to content

fix(hooks): hooks-run exits once its line is written (#167) - #177

Merged
Wolfe-Jam merged 1 commit into
mainfrom
fix/hooks-run-explicit-exit
Oct 21, 2026
Merged

Wolfe-Jam merged 1 commit into
mainfrom
fix/hooks-run-explicit-exit

Conversation

@Wolfe-Jam

@Wolfe-Jam Wolfe-Jam commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

What

faf hooks-run (the pre-commit context guard) now exits as soon as its line is written, on the path that allows the commit. The blocked path already exits (process.exit(1)).

Why

The guard runs inside git commit. On the allowed path it printed its line and then waited for the process to end on its own. The Windows nightly (Node 22, the gating job) failed twice on the same test, hooks.test.ts:233 "STRICT lets an improving commit through":

Run Date Result
39128132835 10-18 fail, 120,672 ms
39279861858 10-19 pass, 1,094 ms
39431845446 10-20 fail, 120,656 ms

It's all or nothing: about 1 s, or the nightly's 120 s child limit. The failing runs printed ✓ faf: context 6% → 21% (+15) (the hook had allowed the commit), then git commit timed out with ETIMEDOUT, and the temp folder was left locked. That is the #167 shape (a child finishes and never exits), inside a commit hook, where a user would feel it.

This doesn't find #167's cause. It takes the wait out of the one place a hang would freeze a user's commit.

Changes

  • src/cli.ts: after hooksRun returns, exit 0 once stdout and stderr have flushed, with a 2 s backstop timer (unref'd). Every path that returns there allows the commit. hooksRun itself is unchanged, so the in-process tests still call it directly.
  • tests/wjttc/hooks.test.ts: a git commit that hits its limit now reads hung child process (#167), like the other spawned-child tests. Temp folders get the name case instead of undefined.

Checked (macOS, Node 24, bun)

  • npx tsc --noEmit clean; npm run lint: 0 errors, src/cli.ts warnings unchanged (2 before, 2 after).
  • npm test: 2,218 pass, 0 fail (3 build-artifact tests need dist/; they pass after npm run build).
  • By hand, through a pipe: an improving commit prints ✓ faf: context 3% → 6% (+3) and exits 0; a regression under --strict prints the ⚠ line and exits 1.

PR CI: all green. The first Windows Node 22 attempt failed in owner-rule-r7 BRAKE R7-3 (bun faf compile / bun faf taf --output hung: the 10-19 nightly shape, a code path this PR doesn't touch); the re-run passed. The hooks commit tests are nightly-only, so the PR job skips them.

The proof is the Windows nightly: this test should stop failing at 120 s on Node 22.

Refs #167

🤖 Generated with Claude Code

The pre-commit guard runs inside `git commit`. On the allowed path it printed
its line and returned, waiting for the process to end on its own; the blocked
path already called process.exit(1). On the Windows nightly (Node 22, 10-18
and 10-20) the allowed path printed "✓ faf: context 6% → 21% (+15)" and
`git commit` then hit the 120 s child limit: the #167 shape inside a hook.

- cli.ts: after hooksRun returns, exit 0 once stdout and stderr have flushed,
  with a 2 s backstop timer (unref'd). hooksRun itself is unchanged, so the
  in-process tests still call it directly.
- hooks.test.ts: a git commit that hits its limit now reads "hung child
  process (#167)"; temp folders get a name ("case") instead of "undefined".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
faf-cli Ignored Ignored Oct 21, 2026 2:31am UTC

@Wolfe-Jam
Wolfe-Jam merged commit 269f246 into main Oct 21, 2026
27 of 29 checks passed
@Wolfe-Jam
Wolfe-Jam deleted the fix/hooks-run-explicit-exit branch October 21, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant