fix: kill leaked child processes on exit, ensure temp file cleanup, add no-leaked-child-processes ESLint rule (#1493)#1494
Open
konard wants to merge 8 commits into
Open
fix: kill leaked child processes on exit, ensure temp file cleanup, add no-leaked-child-processes ESLint rule (#1493)#1494konard wants to merge 8 commits into
konard wants to merge 8 commits into
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: #1493
…#1493) - exit-handler: Send SIGTERM (+ SIGKILL fallback) to surviving child processes before unref, preventing orphaned processes after parent exits - exit-handler: Enhanced logActiveHandles with categorized summary and additional diagnostic fields (exitCode, killed, destroyed) - github.lib.mjs: Wrap temp file I/O in try/finally to prevent leaks when gh commands throw - github-error-reporter.lib.mjs: Same try/finally fix for gist creation and issue creation temp files - solve.auto-pr.lib.mjs: Same try/finally fix for PR creation temp files - solve.results.lib.mjs: Same try/finally fix for PR body update temp files
New custom linting rule that flags bare spawn(), fork(), and execFile() calls whose return value is not captured. Without a reference to the ChildProcess, it can never be killed or monitored, leading to event loop leaks and orphaned processes. Follows the same pattern as no-leaked-timers (#1346) and no-leaked-streams (#1431).
- 15 unit tests for no-leaked-child-processes ESLint rule - 10 unit tests verifying exit-handler kill behavior, diagnostics, try/finally patterns, and rule registration - Case study documenting root causes, timeline, and solutions - Prettier fix for exit-handler detail array formatting
konard
marked this pull request as ready for review
March 29, 2026 18:06
This reverts commit 5af9da1.
Contributor
Author
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
🤖 Models used:
📎 Log file uploaded as Gist (2757KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
Contributor
Author
🔄 Auto-restart triggered (iteration 1)Reason: CI failures detected Starting new session to address the issues. Auto-restart-until-mergeable mode is active. Will continue until PR becomes mergeable. |
- Add changeset for resource leak fixes - Fix prettier formatting in no-leaked-child-processes ESLint rule Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
🔄 Auto-restart-until-mergeable Log (iteration 1)This log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
🤖 Models used:
📎 Log file uploaded as Gist (4272KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
Contributor
Author
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
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.
Summary
Fixes #1493
Finds and fixes all resource leaks identified in the process exit diagnostics log (15 active handles, 4 orphaned child processes, temp file leaks on exception paths) and adds a new ESLint rule to prevent future child process leaks.
Root Causes Found
drainHandles()only called.unref()on surviving ChildProcess handles — processes continued running after parent exittry/finally, so temp files were leaked when commands threw exceptionslogActiveHandles()lacked categorized summary and process state detailsChanges
src/exit-handler.lib.mjssrc/github.lib.mjssrc/github-error-reporter.lib.mjssrc/solve.auto-pr.lib.mjssrc/solve.results.lib.mjseslint-rules/no-leaked-child-processes.mjsspawn()/fork()/execFile()calls with uncaptured return valueseslint.config.mjstests/test-no-leaked-child-processes-rule.mjstests/test-resource-leak-fixes-1493.mjsdocs/case-studies/issue-1493/Resource Leak Prevention — Complete Coverage
no-leaked-timersno-leaked-streamsno-leaked-child-processesTest plan
node tests/test-no-leaked-child-processes-rule.mjs)node tests/test-resource-leak-fixes-1493.mjs)This PR was created by the AI issue solver