Prevent orphaned Harper processes after test runner crashes - #30
Draft
kriszyp wants to merge 4 commits into
Draft
Conversation
Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Co-Authored-By: GPT-5 Codex <noreply@openai.com>
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.
Detached Harper process trees are now supervised by a harness-owned process that detects runner death through a kernel pipe and reaps the tree after
SIGKILL,SIGHUP, or a hard crash. This prevents orphaned Harper instances from permanently holding ports while preserving gracefulkillHarperteardown and the configured Node/Bun runtime.For the human reviewer
ctx.harper.processremains the handle lifecycle APIs consume but now identifies the supervisor;ctx.harper.harperPidexposes the managed runtime PID. A separate lifecycle-handle type would be clearer but would break existingChildProcessconsumers.harperPidis optional on the context type for compatibility with hand-built contexts, even though successful package-managed startup always supplies it. Making it required would strengthen types but break existing test doubles.Verification
runner SIGKILL reaps the supervised Harper tree and releases its portslaunches a separate runner, supervised fake Harper, descendant, and two real TCP listeners; it asserts both PIDs disappear and both ports rebind. The same fixture coversSIGHUP, unexpected supervisor death, and graceful teardown ordering.origin/mainfails withHarper ... should die with its runner; it passes at this head.npm run check— passed.npm run build— passed; package dry-run includesdist/harperSupervisor.jsand its declaration.npm test— 23/23 passed.HARPER_RUNTIME=bun node --test --test-name-pattern='runHarperCommand resolves|runner SIGKILL reaps' test/harperLifecycle.test.ts— 2/2 passed.taskkill /Tbehavior is exercised by the unskipped GitHub Actions matrix after push.Refs #29
Co-Authored-By: GPT-5 Codex noreply@openai.com
🤖 Generated with OpenAI Codex
Complexity: complicated
Review-Coverage: authored=codex; ran=claude,gemini; declined=cursor-grok,cursor-composer,domain; rounds=3 @ bc5fbb4
Human-Review-Need: 4 @ bc5fbb4