Skip to content

Conversation

@9aoy
Copy link
Contributor

@9aoy 9aoy commented Nov 7, 2025

Summary

  • Remove SIGTERM event handler which will cause the main process unexpected exit when the child process exit timeout.
  • Add an exit handler to detect unexpected exit events that occur before the test ends.
image

rstest will tigger exit event in SIGTERM event, and the following code in test will cause main process unexpected exit with code 0.

process.on('exit', (code) => {
	console.log('exit', process.pid, code)
  for (let i = 0; i < Number.MAX_SAFE_INTEGER; i++) {}
  console.log('never called');
  process.exit(0);
});

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 7, 2025 03:57
@netlify
Copy link

netlify bot commented Nov 7, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 50a1e4f
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/690df4166ddcd600084d4af9
😎 Deploy Preview https://deploy-preview-680--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the worker termination handling by moving SIGTERM signal management from manual lifecycle management to Tinypool's built-in teardown hook. The changes simplify the code by removing the module-level onExit function and delegating worker termination to the pool manager.

Key changes:

  • Exported a new teardown function to be called by Tinypool when terminating workers
  • Removed manual SIGTERM handler registration/deregistration from the test execution lifecycle
  • Configured the forks pool to use the new teardown hook via the teardown: 'teardown' option

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/runtime/worker/index.ts Removed module-level onExit function and manual SIGTERM handler management; added exported teardown function for Tinypool lifecycle integration
packages/core/src/pool/forks.ts Configured Tinypool to use the exported teardown function by adding teardown: 'teardown' to pool options

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@9aoy 9aoy changed the title chore: register SIGTERM event before worker terminated chore: remove SIGTERM event handler Nov 7, 2025
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

📝 Rstest Ecosystem CI: Open

suite result
rsbuild ✅ success
rslib ✅ success
rsdoctor ✅ success

@9aoy 9aoy merged commit 6e44cbb into main Nov 10, 2025
17 checks passed
@9aoy 9aoy deleted the pool-teardown branch November 10, 2025 02:53
@9aoy 9aoy mentioned this pull request Nov 10, 2025
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.

2 participants