[BUG] Excessive Orphaned background pytest processes in 2.1.112
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When I run a lot of test-iteration on some sessions, it seems to force the prompt to run all the tests in the background. I've found that these shells still persist 12 hours later, long after the claude session that prompted them was killed. I've had to run killall Python multiple times.
This morning my computer fan was spinning wildly due to 20 python background instances, all orphaned, still running.
What Should Happen?
Pytest should run synchronously, not in background. If async is wanted, do it on a subagent, which already has good lifecycle control. Alternatively fix background pytest lifecycle.
There may be some issue in how background pytest runs, I'm not sure, but claude code prior to version 112 didn't produce this error.
Error Messages/Logs
Steps to Reproduce
Start up 2.1.112.
Run test focused unit test iteration prompts, ideally a few dozen of them, on the same worktree.
Note that the claude code says X shells now, even after the prompt has returned. X may be anywhere from 5-10. Repeat this process for multiple sessions. Kill the terminals (don't use /quit, just close them).
Wait awhile. Note that the python processes never go away, and just keep using resources.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.110
Claude Code Version
2.1.112
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗