fix(hooks): terminate hook child processes when user exits CLI - #2607
Conversation
📋 Review SummaryThis PR addresses a critical bug where Stop hook child processes don't terminate when the user exits the CLI, causing orphaned HookRunner subprocesses. The implementation propagates 🔍 General Feedback
🎯 Specific Feedback🔴 Critical
🟡 High
🟢 Medium
🔵 Low
✅ Highlights
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
fix(hooks): terminate hook child processes when user exits CLI
TLDR
Fixes a bug where Stop hook's child process doesn't exit when user exits CLI (main process closes), causing HookRunner subprocesses to continue running indefinitely.
Key Changes:
MessageBus.request()now supports abort cancellationScreenshots / Video Demo
Dive Deeper
Root Cause:
When user exits CLI via Ctrl+C or other means, the main process exits but Stop hook's child processes (spawned via child_process.spawn) don't automatically terminate since they are independent processes.
Solution:
HookRunner.executeCommandHook()child.kill()to terminate child process when abort is triggeredModified Call Chain:
Reviewer Test Plan
Testing Matrix
Linked issues / bugs