jest: [Bug]: watch mode fails when git maintenance runs

Version

29.4.0

Steps to reproduce

  1. Run your tests with jest --watch and wait until they finish.
  2. In another terminal, run git maintenance run.
  3. The watcher will fail

Expected behavior

Outside process shouldn’t kill the watcher.

Actual behavior

Watcher dies immediately with

Error: EPERM: operation not permitted, lstat 'C:\Workspace\my-project\.git\objects\dc\a-very-long-hash'
Emitted 'error' event on NodeWatcher instance at:
    at C:\Workspace\my-project\node_modules\jest-haste-map\build\watchers\NodeWatcher.js:274:14
    at FSReqCallback.oncomplete (node:fs:207:21) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'lstat',
  path: 'C:\\Workspace\\my-project\\.git\\objects\\dc\\a-very-long-hash'
}

I have also seen it point to .git\objects\maintenance.lock.

Additional context

This other issue is where I found the suggestion that it was a background git maintenance command that was causing the conflict, and once I knew that it was easy to reproduce.

Environment

System:
    OS: Windows 10 10.0.22621
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
  Binaries:
    Node: 18.12.1 - ~\AppData\Local\fnm_multishells\30672_1675721836564\node.EXE
    npm: 8.19.2 - ~\AppData\Local\fnm_multishells\30672_1675721836564\npm.CMD
  npmPackages:
    jest: ^29.3.1 => 29.4.0

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 3
  • Comments: 26 (9 by maintainers)

Most upvoted comments

Any news about that? 😃

I think the issue linked to has a different cause than this one. https://github.com/iden3/snarkjs/issues/57#issuecomment-703231979

I get this issue often also, I think there is a bug in how jest-haste-map is handling file watcher events on Windows. In my case if it is watching a folder that also contains a Visual Studio project that is creating temporary .vs files then I get these errors quite often:

image

Other node.js packages have run into this and found a way to fix it, for example, see: https://github.com/iden3/snarkjs/issues/57

I think that the two actions are need: ignore errors (in case error really happens) and fix VCS directories check.