-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Using lodash causes "open handles" warnings #6639
Comments
Seems like an odd false positive. The promise created here is never destroyed: https://github.com/lodash/lodash/blob/ab960bdc964fa1b1c46630f6d6681e55f6af862c/.internal/getTag.js#L30 The code we use is this: https://github.com/facebook/jest/blob/664681a57e4e034bfb80bd34218625cd0cceed08/packages/jest-cli/src/get_node_handles.js#L17-L43 Basically for every async thing, stick it in a map, and remove it after it's destroyed. Anything left (excluding Jest internals) are reported as open handles. Not sure why that promise in Lodash isn't destroyed... @jdalton ideas? Jest exits cleanly, so it might be that we just need to GC the test file or something like that earlier? Or wait a tick or two after tests are done before we report on the handles. We could also wait for say 100ms before printing, allowing more handles to be cleaned up. We currently wait a full second before asking user to try |
Hi @SimenB! That's neat, but also 🤔 |
We keep a second copy around (so that user code messing with |
Those are helpful comments. I'm not sure if this adds clarity for either of you, but I just tried not loading lodash at all in my tests or source. I still see open handles reported by jest: Promise.resolve();
describe(`Calling Promise.resolve()`, () => {
it(`causes these tests to show open handles`, () => {
expect(1).toEqual(1);
});
});
I'm guessing that this has something to do with Promise.resolve() being called at the module level, and not lodash doing something funky. I'm not sure though, I'm hazy on how |
Lodash seems to be a dependency (in several places) of Babel, according to some |
I think we should rework it to wait for some time (maybe 1000ms to match when we hint about the flag) before collecting open handles. The process doesn't hang when importing lodash which is the thing the flag is meant to help you find |
I'm facing this problem too :( |
If you need to use |
Consistently seeing the same issue:
|
This has been working fine in jest 23.2.0 |
Running into multiple of this issues on jest 23.4.0
|
Just pasting stack traces helps no one. Most likely it's an issue in your own code, not here. The flag's there to help you track it down, not report issues in this tracker. The lodash one has a small reproduction, and is obviously wrong, so that's fine.
|
@SimenB Maybe I had to explain why I think some of the stack traces that I posted seem related to me.
I'm removing the other stack trace so that it doesn't generate confusion. |
See also petkaantonov/bluebird#1541 As mentioned there, I think the fix is to ignore promises as they don't keep the process open anyways |
Also, we currently do not print stuff created in tests as hanging, see open PR: #6263 |
@SimenB I might be able to spend time on a fix. What's the package I should start in? |
I have an open PR already, but thanks for offering! #6716 |
This resolves an issue with jest that was preventing tests from completing on windows environments. See jestjs/jest#6639
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. |
🐛 Bug Report
Something about Lodash causes Jest to detect "open handles"
To Reproduce
Run jest with
--detectOpenHandles
and require lodash. I'm not sure what the exact conditions going on here, but it's pretty reliably reproducible with the repo below.The behavior looks like this:
Expected behavior
I wouldn't expect to see open handles for
require()
callsLink to repo
Run
npx envinfo --preset jest
The text was updated successfully, but these errors were encountered: