fix(core): properly cleanup worker processes on SIGINT/SIGTERM#880
Merged
fix(core): properly cleanup worker processes on SIGINT/SIGTERM#880
Conversation
When tests are interrupted (e.g., with Ctrl+C/SIGINT), tinypool worker processes were not properly cleaned up and continued running indefinitely. This fix adds signal handlers for SIGINT and SIGTERM that properly: - Call runGlobalTeardown() - Call pool.close() to terminate worker processes - Call closeServer() to clean up the dev server The fix applies to both watch mode and non-watch mode. Fixes #876
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where worker processes were not properly cleaned up when tests were interrupted with SIGINT or SIGTERM signals. The fix adds signal handlers that ensure proper cleanup of global teardown, worker pool, and dev server resources.
Changes:
- Added SIGINT/SIGTERM signal handlers to properly clean up resources on interruption
- Modified Ctrl+C handling in CLI shortcuts to delegate to signal handlers
- Implemented cleanup guards to prevent duplicate cleanup operations
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/core/src/core/runTests.ts | Added signal handlers for both watch and non-watch modes with cleanup() function to handle runGlobalTeardown, pool.close, and closeServer |
| packages/core/src/core/cliShortcuts.ts | Changed Ctrl+C handling to send SIGINT signal instead of calling process.exit(0) directly |
| packages/core/src/cli/commands.ts | Added signal handler installation for non-watch mode with cleanup in finally block |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
When tests are interrupted (e.g., with Ctrl+C/SIGINT), tinypool worker processes were not properly cleaned up and continued running indefinitely.
This fix adds signal handlers for SIGINT and SIGTERM that properly:
The fix applies to both watch mode and non-watch mode.
Related Links
Fixes #876
Checklist