Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test run of code running process.exit(1) with workers hangs indefinitely #6726

Closed
theneva opened this issue Jul 20, 2018 · 6 comments
Closed

Comments

@theneva
Copy link
Contributor

theneva commented Jul 20, 2018

🐛 Bug Report

Test run of several test files with workers (i.e., not in band) sometimes hangs indefinitely if the code under test calls process#exit.

Demo note: y is an alias for yarn, and the code is found at https://github.com/theneva/jest-process-exit.

run that hangs

Here's the output with the diff from #6714 applied:

run with output regarding process#exit call from #6714

To Reproduce

Steps to reproduce the behavior:

  1. Have a test subject that calls process.exit(1)
  2. Have one file with a test running that code, and (at least) one other test file which does not run any code calling process#exit
  3. Run the test files using workers (that is, without --runInBand)
  4. Hope for the best: the test run will sometimes simply terminate (possibly due to invocation order). Example:

run that simply terminates

A run of only the test file with the failing test always terminates immediately after process#exit is called, and the same applies when running multiple test files in band.

Expected behavior

The test run should exit with an error message instead of continuing indefinitely.

Additionally, it would be great with feedback on why the test failed via something like @SimenB's PR #6714.

Link to repl or repo (highly encouraged)

https://github.com/theneva/jest-process-exit is the smallest I could manage.

Run npx envinfo --preset jest

Paste the results here:

System:
  OS: macOS High Sierra 10.13.6
  CPU: x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
Binaries:
  Node: 8.11.2 - ~/.nvm/versions/node/v8.11.2/bin/node
  Yarn: 1.7.0 - /usr/local/bin/yarn
  npm: 6.1.0 - ~/.nvm/versions/node/v8.11.2/bin/npm
npmPackages:
  jest: ^23.4.1 => 23.4.1
@cirias
Copy link

cirias commented Jul 20, 2018

Found the same issue yesterday! https://github.com/cirias/hanging-jest

@SimenB
Copy link
Member

SimenB commented Aug 8, 2018

@mjesun thoughts on this one?

@mjesun
Copy link
Contributor

mjesun commented Aug 8, 2018

@theneva Would you mind patching #6815 locally (on your node_modules) and checking? This should be good enough, as process.exit (the real one) won't be exposed anymore :)

@theneva
Copy link
Contributor Author

theneva commented Aug 8, 2018

@mjesun with #6815 applied the tests pass consistently! Nice! 🎉

@SimenB
Copy link
Member

SimenB commented Oct 20, 2018

Covered by #6714 IMO. Easy enough for people to stub out process.exit if they don't want to exit. Maybe we want to update the message? Not sure

@SimenB SimenB closed this as completed Oct 20, 2018
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants