jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
43.99k stars 6.42k forks source link

[Bug]: Killed worker hangs endlessly and prevents Jest test execution from finishing #13864

Closed Llois41 closed 1 year ago

Llois41 commented 1 year ago

Version

29.4.1

Steps to reproduce

  1. Create a new project with following files:

package.json:

{
  "devDependencies": {
    "@types/jest": "^29.4.0",
    "jest": "^29.4.1"
  }
}

index.spec.js:

test('kill process', () => {
    process.kill(process.pid, 'SIGSTOP')
    expect(1 + 3).toBe(4);
});

test('green test', () => {
    expect(1 + 3).toBe(4);
});

test('another green test', () => {
    expect(1 + 4).toBe(5);
});

index2.spec.js:

test('green test', () => {
    expect(1 + 3).toBe(4);
});

test('green test 2', () => {
    expect(1 + 3).toBe(4);
});

test('green test 3', () => {
    expect(1 + 3).toBe(4);
});

test('green test 4', () => {
    expect(1 + 3).toBe(4);
});

and an empty jest.config.js.

  1. Install dependencies & run tests via node_modules/jest/bin/jest.js --workers=2

=> Jest will hang since one worker was killed.

Expected behavior

I expect jest not to hang endlessly, but instead finish gracefully.

Actual behavior

Jest test execution hangs forever.

Additional context

Seems a lot like the bug in https://github.com/facebook/jest/issues/13183 But still happens in the latest Jest version.

Environment

System:
    OS: macOS 13.2
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 16.18.0 - ~/.nvm/versions/node/v16.18.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.18.0/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.0/bin/npm
  npmPackages:
    jest: ^29.4.1 => 29.4.1
juan-fernandez commented 1 year ago

https://github.com/facebook/jest/issues/13976 is probably a duplicate from this one

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] commented 1 year ago

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.