Skip to content

fix(task): kill entire process group on BackgroundTaskRuntime dispose + test:noforce#162

Open
hernandez42 wants to merge 1 commit into
OpenBMB:mainfrom
hernandez42:fix/background-task-process-group
Open

fix(task): kill entire process group on BackgroundTaskRuntime dispose + test:noforce#162
hernandez42 wants to merge 1 commit into
OpenBMB:mainfrom
hernandez42:fix/background-task-process-group

Conversation

@hernandez42
Copy link
Copy Markdown

Summary

Fix BackgroundTaskRuntime subprocess leak and add open-handle detection to test suite.

Changes

src/task/runtime/BackgroundTaskRuntime.ts

  • On Unix, use process.kill(-child.pid, signal) to kill the entire process group (negative PID = process group), not just the shell process
  • This catches detached bash sub-processes that would otherwise leak
  • Windows still uses child.kill(signal) (TerminateProcess)

package.json

  • test now runs without --test-force-exit (natural exit, exposes open handles)
  • Added test:force as the old --test-force-exit mode
  • Added test:noforce as explicit alias for natural-exit mode

Why this matters

--test-force-exit was masking open handles from background tasks, file watchers, and MCP connections. Running without it (npm test) now naturally exposes any real leaks:

npm test        # natural exit, detects open handles
npm run test:force   # legacy mode with --test-force-exit
npm run test:noforce # same as npm test

Verification

npm test
# Should pass AND exit cleanly without force-exit

Co-authored-by: Xuanji xuanji@ouvaton.org

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.

1 participant