jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
44.12k stars 6.44k forks source link

Error: Error watching file for changes: EMFILE #3436

Closed kirkstrobeck closed 7 years ago

kirkstrobeck commented 7 years ago

I know others have posted this issue, but it seems that they are aging and using old versions. I have tried everything from other issues.

Here is the error I get:

$ jest --watch # or with $ jest --watch --no-watchman
2017-05-02 09:49 node[8980] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-02 09:49 node[8980] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-02 09:49 node[8980] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: Error watching file for changes: EMFILE
    at exports._errnoException (util.js:1050:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1376:11)
error Command failed with exit code 1.

Versions:

kirkstrobeck commented 7 years ago

This problem exists with the following versions

It works in

thymikee commented 7 years ago

Does it happen in v20?

kirkstrobeck commented 7 years ago

Yes, the error is present in v20.0.0.

2017-05-08 05:30 node[6062] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-08 05:30 node[6062] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-08 05:30 node[6062] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: Error watching file for changes: EMFILE
    at exports._errnoException (util.js:1050:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1376:11)
error Command failed with exit code 1.
thymikee commented 7 years ago

And have you tried it with watchman (brew install watchman)?

kirkstrobeck commented 7 years ago

Yes

thymikee commented 7 years ago

Any chance for a repro? It's hard to debug without it :(

joevandyk commented 7 years ago

brew install watchman worked for me.

renchap commented 7 years ago

Same here, it did not work with jest --watch or jest --watch --no-watchman (watchman was not installed):

2017-05-28 18:57 node[17087] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-28 18:57 node[17087] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-28 18:57 node[17087] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: Error watching file for changes: EMFILE
    at exports._errnoException (util.js:1050:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1374:11)

I installed watchman using brew, and jest --watch now works. jest --watch --no-watchman still fails.

Jest v20.0.4 Node v7.10.0 MacOS 10.12.5

fitfab commented 7 years ago

I get similar error when i install "pact" and then i tried to run npm test. I using create-react-app to setup my project and using node v7.9.0

thisconnect commented 7 years ago

new sane version fixed this error for me see https://github.com/amasad/sane/pull/97#issuecomment-309203580

wayneseymour commented 7 years ago

Same problem, MAC OS X Sierra Node v7.8.0 Jest ^20.0.4

melkristian commented 7 years ago

brew install watchman worked for me too using NodeJS v6.9 but what I don't understand is the watchman dependence itself. Is this a dependency of the NodeJS version on Mac OS X Sierra? Where does this fit in the dependency tree?

kirkstrobeck commented 7 years ago

https://github.com/facebook/jest/issues/1767#issuecomment-313434888

Premjeet-Singh commented 6 years ago

brew install watchman worked for me.

gazzwi86 commented 6 years ago

I had this error, but found that if I changed the command I used to run jest in watch mode, it worked.

"test": "jest",
"test:watch": "npm run test -- --watch",

became:

"test": "jest",
"test:watch": "npm run test --watch",
darylshy commented 6 years ago

brew install watchman worked... until it didn't... :-/ quit my tests and ran it again. And we're back at square one. uninstalled watchman, reinstalled watchman. no-dice.

thujone commented 6 years ago

brew install watchman worked for me. And I think watchman had gotten broken somehow because I accidentally closed a terminal window while installing a react package using npm. Clean installing everything both in the project and globally didn't seem to help, but re-installing watchman did.

Leotw commented 6 years ago

Yeah! brew install watchman for work

zxzl commented 6 years ago

Yeah! brew install watchman for work (2)

kateryname commented 6 years ago

Yeah! brew install watchman for work (3)

amandapouget commented 6 years ago

ditto to watchman

carmanchris31 commented 4 years ago

I had this error, but found that if I changed the command I used to run jest in watch mode, it worked.

"test": "jest",
"test:watch": "npm run test -- --watch",

became:

"test": "jest",
"test:watch": "npm run test --watch",

The extra -- is the delimiter that tells npm to forward the remaining parameters to the referenced script.

npm run test -- --watch would run jest --watch but npm run test --watch would ignore the argument and just run jest. You can verify this in your console output.

github-actions[bot] commented 3 years ago

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. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.