--detectOpenHandles prints nothing, just hangs

See original GitHub issue

🐛 Bug Report

When I run my test suite I get one of these 2 messages:

A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --runInBand --detectOpenHandles to find leaks.

or

Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren’t stopped in your tests. Consider running Jest with --detectOpenHandles to troubleshoot this issue.

For one, I think the mention of --runInBand in the first message is probably not necessary. But in any case, when I start running jest with --detectOpenHandles, I get no output, jest just hangs after finishing the tests.

Expected behavior

I would expect detectOpenHandles to give me actionable output.

envinfo

$ npx envinfo --preset jest
npx: installed 1 in 1.775s

  System:
    OS: macOS 10.15.2
    CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
  Binaries:
    Node: 10.18.0 - ~/.nvm/versions/node/v10.18.0/bin/node
    Yarn: 1.21.1 - /usr/local/bin/yarn
    npm: 6.13.6 - ~/.nvm/versions/node/v10.18.0/bin/npm
  npmPackages:
    jest: ^25.1.0 => 25.1.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:147
  • Comments:54 (1 by maintainers)

github_iconTop GitHub Comments

91reactions
Prestaulcommented, Mar 13, 2020

I’m seeing the same issue. I’m not asking for help debugging my code, I’m pointing out a “concrete problem in jest”. In some code bases, when running jest with --runInBand --detectOpenHandles, as recommended by the CLI, the tests complete with no reported issues and jest hangs.

I have not been able to isolate a minimal reproduction, but this does not mean the issue isn’t real. Unless this is expected behavior, please reopen in acknowledgement that this is clearly affecting users.

76reactions
iyo-bemoorecommented, Mar 19, 2020

this solves it “test”: “jest --watch --runInBand --detectOpenHandles”

Read more comments on GitHub >

github_iconTop Results From Across the Web

are there side effects of running jest with --detectOpenHandles
From the documentation, the detectOpenHandles option is for: Attempt to collect and print open handles preventing Jest from exiting cleanly.
Read more >
sunil pai, inc. on Twitter: "Has jest's —detectOpenHandles ...
Has jest's —detectOpenHandles ever worked for anyone? ... It just prints out an error that there's still an open handle.
Read more >
How to find the root cause of a failing test if Jest doesn't tell ...
By using this command, Jest should print the actual exception which should be enough to locate the bug in the code. jest --detectOpenHandles....
Read more >
Why Jest freezes after tests run? (Jest hangs indefinitely)
If you noticed that Jest (npm / yarn) test hang at the end of the test execution ... --detectOpenHandles - it attempts to...
Read more >
How To Fix: Jest Did Not Exit - DONN FELKER
--detectOpenHandles and the tests just hung. Nothing happened. Solution. After some experimenting, I realized I was not destroying my Knex ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found