jest: Jest fails with EBADF: bad file descriptor, close
š Bug Report
Jests fails multiple times with:
jest: failed to cache transform results in: C:/Users/Henning/AppData/Local/Temp/jest/jest-transform-cache-21ff455c7f0bd09e66d08b5df7fc2a40-e2c4083dbe718f612529eff10eba50fe/e3/error-guard_e3806b360161eb5615267fc2e1997a27
Failure message: EBADF: bad file descriptor, close
at Object.closeSync (node_modules/graceful-fs/graceful-fs.js:52:27)
To Reproduce
Run react-native init
, copy the file App.js
in __Tests__
several times (more than 10 times).
Run yarn test
.
Expected behavior
All tests pass.
Run npx envinfo --preset jest
System:
OS: Windows 10
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Yarn: 1.10.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 12
- Comments: 41 (17 by maintainers)
Commits related to this issue
- fix: tests failed in windows turn on runInBand before https://github.com/facebook/jest/issues/7709 gets solved — committed to nuxt/nuxt by clarkdo 5 years ago
I can confirm 23.6.0 is affected too and was fixed by using npm resolutions
and
in package.json
this was happening with jest 23.6 for my team as well. I went ahead and added
"write-file-atomic": "2.4.1"
toresolutions
in mypackage.json
:"resolutions": { "write-file-atomic": "2.4.1" },
24.1.0 is out: https://github.com/facebook/jest/commit/8a2ea1e83845497fa7756b44c91f6ff97eb02692
Feels a bit dirty using resolutionsā¦ do we know when a 24.0.1 or 24.1 will be out?
Thatās an issue either with your network or a proxy/registry of some kind. Itās definitely available:
https://www.npmjs.com/package/jest
No, not unless absolutely necessary. And we have donāt really have a fix. The āfixā is to rollback
write-file-atomic
, which you can do yourself with a lockfile or yarnāsresolutions
.2.4.2
is the one with the error, so use2.3.0
(what jest 23 came with) or2.4.0
/2.4.1
Same problem once upgrading to jest 24, windows 10. Iāve downgraded write-file-atomic to 2.4.1 with manual copying of an old version and it stopped having errors. re installing and the error comes back. i cleared my cache before each test.
Related to #4444 (last few comments there), seems like something in the upgrade from
write-file-atomic
2.3.0 -> 2.4.2 broke something.Can you try to either manually edit
node_modules/write-file-atomic/index.js
or use yarnresolutions
to force 2.3.0 and see if that fixes your error?Diff: https://github.com/npm/write-file-atomic/compare/v2.3.0...v2.4.2
I encountered this problem today on our large scale project. We use locked 23.6.0 jest version. Could the fix be also applied to 23.x versions?
Iām also seeing this error after upgrading. Was previously using jest@23.6 successfully. Post upgrade getting this cache error randomly.
Oh, and btw, if you use Yarn, feel free to use the
"resolutions"
field in package.json to get this done, or use thepatch-package
project š22.4 also has this issue
Thatās great, just letting the next google-fu-master that finds this thread to avoid trying the workaround if they might be using yarn workspaces.
Iāve opened up #7725. @pribilinskiy it would be awesome if you could test by installing
write-file-atomic@2.4.1
(jest comes with2.4.2
) locally and see if it fixes your issue. Either usesresolutions
if you use yarn, or manually replacing innode_modules
Plain jest.
abbreviated jest.config.js