Skip to content

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

@theneva

Description

@theneva

🐛 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions