-
Notifications
You must be signed in to change notification settings - Fork 466
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
jest run reports "A worker process has failed to exit gracefully ..." #524
Comments
👋 Deej This is tricky. Importing DTL/index is synchronous, so it shouldn't really do anything that causes Promises or timeouts to leak... I assume your tried The only kind of suspicious thing I can think of is that importing |
Yes, I should have mentioned I did try with the runInBand and detectOpenHandles. And "of course" the problem went away when I did that. And the @testing-library/dom we're getting is 7.2.1 🤷 |
is the command suppose to be jest --runInBand --detectOpenHandles |
@SarthakJha I think so. Why do you ask? |
I am able to reproduce permanently in one of my tests, mine has something to do with a mocked function that is used with the await js keyword |
@favs-sama I assume it is too complex to extricate that out into a repeatable simple test case? |
We also see this message.
Is there some way to identify which tests might be leaking? |
You could try only running specific test files until you can isolate which ones are causing issues with open handles. If it's many of them, you should check your setup scripts and test utilities. |
so i only see this when i run the whole suite. in my test files, there are maybe 5 directories that contain all tests and running each one like |
@omgoshjosh Not going crazy (well, maybe you are, that's independent of this ;-) ). That's exactly what I see too. I spent some time at one point pruning down the set of tests, hoping to isolate "the one bad test" causing this. but, as I recall eventually the problem seemed more a function of number of tests and it doesn't seem tied to any individual test in any obvious way. |
yes and even when i run a large subset, i can get the error to appear sometimes and disappear other times. it seems possible that the timing of the suite may have an impact. |
I am running only one test file and it throws this error. No idea why it happened |
@tonystaark if it is a single test and it is repeatable, is it something you could share in some way? Might help the maintainer to hunt it down. |
I see this error in a test package for backend code (i.e. doesn't involve react, this library, or the dom) So this can probably be closed. Relevant jest issue: jestjs/jest#9473 |
This error suddenly appears today after having updated dependencies (no semver major updates) 🤔 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 --detectOpenHandles to find leaks.
Test Suites: 113 passed, 113 total
Tests: 494 passed, 494 total
Snapshots: 134 passed, 134 total
Time: 14.17 s
Ran all test suites matching /\/test\//i. Node.js v12.19.0
jest 26.6.3 If I rollback to previous dependency versions I don't longer have the error 🤔 Edit: I don't have React as dependency |
Could be a regression of #801 ? @kentcdodds |
Possibly, I'm not sure though. cc @romain-trotard |
Are you all running jest using a Mac? If so it may be related to jestjs/jest#10777 and fsevent bug fsevents/fsevents#345 that has just been fixed 🤔 |
I presume there's another issue people are referring to here, but just incase someone finds themselves reading. For me deleting node modules and the yarn lock file then re installing dependencies resolved this issue 🤷🏻♂️ |
In line with @seancwalsh, I can confirm that doing a clean install and bumping Jest to 26.6.3 seems to fix it. |
Sounds like this is unrelated to Testing Library, so I'm going to close it :) Thanks everyone! |
In my scenario, there were two different histories In the same test I fixed this issue by changing every jest |
I did face the same thing in 2021, |
2 things that help me to troubleshoot this issue
My problem was that I was trying to close an expressjs server but took time. // this was not working
afterAll((done) => {
await server.close();
done();
});
//this worked
afterAll((done) => {
server.close(() => {
done();
});
}); To solve the problems that are about timers, use
|
I can get this all the time when using a utility package I use for my work (jest 26.6.3, node 12.20) isolated test:
BTW, this package uses jsdom internally. |
For anybody who gets here through search results, – try to check if you are really not forgetting to |
Thanks @parzhitsky! It turns out I needed this for proper shutdown of the pg-promise resources: afterAll(() => {
db.$pool.end();
}); |
I also saw this with my tests... hunted down the specific file, isolated the test and... used "setTimeout" to construct the rendered comp. Figuring exactly the piece of code is really hard, and I assumed it was probably due to some Promise deep inside my component tree (really big ... 😥). Updated my
And now I don't see the issue anymore... though I am really curious to see what changed between 27.3 and 27.4 now. |
Added DOMPurify module for sanitizing user input for forms. Update vscode launch.json for debugging. Update `.gitignore` to ignore files prefixed with a single underscore for files that I do not want added to the repository. Update test script to fix error adding the `--detectOpenHandles` argument. testing-library/dom-testing-library#524 Update tests - Added mocks for the app setup for the theme, routing, and state store. - Created `commonSetup.js` module that re-exports multiple mocks for a single import instead of multiple lines of mock imports. - Refactor `Home.test.tsx` to use the new `commonSetup.js` for importing the mocks.
Added DOMPurify module for sanitizing user input for forms. Update vscode launch.json for debugging. Update `.gitignore` to ignore files prefixed with a single underscore for files that I do not want added to the repository. Update test script to fix error adding the `--detectOpenHandles` argument. testing-library/dom-testing-library#524 Update tests - Added mocks for the app setup for the theme, routing, and state store. - Created `commonSetup.js` module that re-exports multiple mocks for a single import instead of multiple lines of mock imports. - Refactor `Home.test.tsx` to use the new `commonSetup.js` for importing the mocks. testing Netlify webhook test test added site id for netlify added auth token for netlify using cli typo vx.x.x specified build dir to deploy vx.x.x specified build dir to deploy
We ran into this issue in our tests and it turned out to be someone using Ultimately, it seems like the cause is that RTL is configured to timeout tests at 1s (per this documentation) and Jest is configured to kill its workers after 500ms (see their source). Changing our default RTL config to timeout at less than 500ms fixed things for us.
|
Yikes, I didn't realise that - I've had performance issues with RTL tests in the past (e.g. #820) where one of the solutions was to up the jest timeouts and asyncUtilTimeout a bit. Going that low would probably cause a lot of tests to fail for us 🤔 |
DOM Testing Library
version: 7.2.1node
version: 10.15.3npm
(oryarn
) version: 6.13.6Relevant code or config:
What you did:
See above.
What happened:
Jest (?) is reporting the warning
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.
at the end of a test runReproduction:
Probably pretty hard. See below.
Problem description:
The problem is that when we
require('@testing-library/dom');
. (even if we never callconfigure()
or any other RTL code) at the end of the test run of 3500 tests we get the above warning. Trying to subdivide the tests to find the "offending test", makes the problem go away. So, it isn't directly due to some misbehaving test.Interestingly, if we use
require('@testing-library/react');
and do not directly import.../dom
we don't see the problem.I'm not seriously expecting that you can fix this given the paucity of information I have to offer. And given that we're on React 15, node 10 (though current Jest) it is entirely possible that this is a result of some older version of things that doesn't happen on newer configurations. Instead, I'm filing this mainly to let you know this is happening, and to leave a record to allow others to know that someone else has seen this problem.
(the workaround appears to just be to not do any configuration of
@testing-library/dom
:-)The text was updated successfully, but these errors were encountered: