Skip to content

fix: Hook stdin reader hangs on parallel agent completions (#1021)#1027

Open
justinkatz94-glitch wants to merge 1 commit intodanielmiessler:mainfrom
justinkatz94-glitch:fix/1021-hook-stdin-reader-hang
Open

fix: Hook stdin reader hangs on parallel agent completions (#1021)#1027
justinkatz94-glitch wants to merge 1 commit intodanielmiessler:mainfrom
justinkatz94-glitch:fix/1021-hook-stdin-reader-hang

Conversation

@justinkatz94-glitch
Copy link
Copy Markdown

Summary

Fixes three bugs in PAI hook stdin reading that cause intermittent hangs when multiple agents complete simultaneously (e.g., council debates with 4+ parallel agents).

  • hook-io.ts: Dangling Bun.stdin.stream().getReader() after Promise.race timeout — added reader.cancel(), increased timeout 500ms→2000ms
  • PRDSync.hook.ts: Synchronous readFileSync(0) blocks indefinitely under CPU contention — converted to async Bun.stdin.stream() with timeout + cancel
  • IntegrityCheck.hook.ts: Same dangling reader pattern — added cancel + timeout increase

Test plan

  • All 3 hooks exit cleanly with empty stdin
  • All 3 hooks parse realistic JSON payloads correctly
  • Concurrent execution (4 parallel instances) — no hangs
  • Existing PRDSync/IntegrityCheck functionality preserved

Closes #1021

🤖 Generated with Claude Code

…ssler#1021)

Three bugs in PAI hook stdin reading code cause intermittent hangs
when multiple agents complete simultaneously (e.g., council debates):

1. hook-io.ts: Dangling Bun stdin reader after Promise.race timeout
   - Added reader.cancel() after timeout, increased timeout 500ms→2000ms

2. PRDSync.hook.ts: Synchronous readFileSync(0) blocks indefinitely
   - Converted to async Bun.stdin.stream() with 2s timeout + cancel

3. IntegrityCheck.hook.ts: Same dangling reader as hook-io.ts
   - Added reader.cancel() + timeout increase

Closes danielmiessler#1021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Hook stdin reader hangs on parallel agent completions (council debates)

1 participant