cypress: Cypress crashing on Linux > System limit for number of file watchers reached 'package.json'

Hi, daily user of Cypress here. Just found this corner case where Cypress.js is crashing.

Steps to reproduce

Not exactly sure but overall this is the scenario.

  1. Open a bunch of processes which subscribe to package.json changes. In my case: two WebStorm windows & react build tools
  2. Open Cypress, open the project directory and run all tests in Chrome
  3. Cypress will crash right after opening Chrome with the following output:

Cypress process output

 {
  errno: -28,
  syscall: 'watch',
  code: 'ENOSPC',
  path: '/home/jake/DEV/dedupe-refresh/package.json',
  filename: '/home/jake/DEV/dedupe-refresh/package.json'
}
Error: ENOSPC: System limit for number of file watchers reached, watch '/home/jake/DEV/dedupe-refresh/package.json'
    at FSWatcher.start (internal/fs/watchers.js:165:26)
    at Object.watch (fs.js:1329:11)
    at createFsWatchInstance (/home/jake/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:38:15)
    at setFsWatchListener (/home/jake/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:81:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/jake/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:233:14)
    at FSWatcher.NodeFsHandler._handleFile (/home/jake/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:262:21)
    at FSWatcher.<anonymous> (/home/jake/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/node_modules/watchify/node_modules/chokidar/lib/nodefs-handler.js:495:21)
    at callback (/home/jake/.cache/Cypress/4.3.0/Cypress/resources/app/packages/server/node_modules/graceful-fs/polyfills.js:289:20)
    at FSReqCallback.oncomplete (fs.js:159:5)

GET /__cypress/tests?p=cypress/support/index.js-271 - - ms - -
GET /__cypress/tests?p=cypress/integration/2.rwandaAllDedupes.test.js-101 - - ms - -
GET /__cypress/tests?p=cypress/integration/1.filterOptions.test.js-697 - - ms - -
/home/jake/.cache/Cypress/4.3.0/Cypress/Cypress --no-sandbox -- --cwd /home/jake/DEV/dedupe-refresh[19436]: ../../third_party/electron_node/src/node_platform.cc:449:std::shared_ptr<PerIsolatePlatformData> node::NodePlatform::ForIsolate(v8::Isolate *): Assertion `data' failed.
The Test Runner unexpectedly exited via a exit event with signal SIGABRT

Please search Cypress documentation for possible solutions:

https://on.cypress.io

Check if there is a GitHub issue describing this crash:

https://github.com/cypress-io/cypress/issues

Consider opening a new issue.

----------

Platform: linux (Ubuntu Linux - 19.10)
Cypress Version: 4.3.0

System

Ubuntu 19.10 Cypress 4.3.0 node.js v12.16.1


Thanks! I love cypress. Let me know if I can provide more info.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (2 by maintainers)

Most upvoted comments

Also, FYI, I have file watching explicitly disabled in cypress.json, but it’s still crashing:

{
  "baseUrl": "http://localhost:3003",
  "watchForFileChanges": false,
  "defaultCommandTimeout": 10000
}

Hi,

I think I meet the same problem that the options for disabling file watch do not work (it’s happened at 7.7.0):

https://github.com/berviantoleo/react-multi-crop/runs/3018043472?check_suite_focus=true

Since my configuration like this:

https://github.com/berviantoleo/react-multi-crop/blob/master/examples/demo/cypress.json

But it’s fine when at 7.6.0:

https://github.com/berviantoleo/react-multi-crop/runs/2958413049?check_suite_focus=true

The chokidar dependency seems to be the problem. The fix that works for me is to set CHOKIDAR_USEPOLLING: CHOKIDAR_USEPOLLING=1 cypress run ...

See also: https://github.com/cypress-io/github-action/issues/317#issuecomment-798785420

I am running into this on 7.7.0. This is despite using cypress run, which the documentation suggests should not be watching files. I’ve tried setting watchForFileChanges to false via the command line and cypress.json, but neither seems to take effect. I am running using the docker image cypress/included:7.7.0

@jennifer-shehane True, I am going to do that.

However, I’d suggest the expected behavior should be not to crash the entire process over this.

I’d suggest increasing the limit for the number of file watchers your system can watch https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

I’d suggest increasing the limit for the number of file watchers your system can watch https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

@jennifer-shehane, this is becoming a blocking issue for many devs out here, could it be prioritized higher in your teams list? it would be highly appreciated.

A couple of thoughts:

  • This is happening for my team in our CI environment where it is not easy to make changes for large enterprises.
  • As @jakub-bao pointed out earlier, this should not fail the whole process. I think test should continue to run with auto-disabling of watcher and a warning about watcher reaching limit.

Thanks, Ankit

Also, FYI, I have file watching explicitly disabled in cypress.json, but it’s still crashing:

{
  "baseUrl": "http://localhost:3003",
  "watchForFileChanges": false,
  "defaultCommandTimeout": 10000
}

It doesn’t make sense to put it in the config file, because you do want it to watch for changes while writing/debugging tests. The correct way is to pass an override through the CLI:

cypress run --config watchForFileChanges=false

See: https://docs.cypress.io/guides/guides/command-line#cypress-run-config-lt-config-gt

@adi518 , I agree with your approach but did this work for you though? it did not for me. Thanks.

You are right, it doesn’t work. I just tried it myself, since I have the same issue. Seems like the only workarounds now are to to modify the limit or downgrade Cypress to 7.6.0 (in package.json -> "cypress": "7.6.0"), notice the fixed version, otherwise it will still install 7.7.0.

Thank you @Asharma86 for connecting the two issues,

I apologize for not responding earlier.

To everyone following this issue, given the number of open issues we have it it gets very hard to follow up on closed ones. When we are 100% sure the same use case with the same reproduction is actually failing then we will re-open the issue and follow up on it.

If you have a blocking issue that is remotely linked, please open a new one. We can track duplicate issues, but we cannot track closed ones.

Thank y’all in advance for understanding

Also, FYI, I have file watching explicitly disabled in cypress.json, but it’s still crashing:

{
  "baseUrl": "http://localhost:3003",
  "watchForFileChanges": false,
  "defaultCommandTimeout": 10000
}

It doesn’t make sense to put it in the config file, because you do want it to watch for changes while writing/debugging tests. The correct way is to pass an override through the CLI:

cypress run --config watchForFileChanges=false

See: https://docs.cypress.io/guides/guides/command-line#cypress-run-config-lt-config-gt

@adi518 , I agree with your approach but did this work for you though? it did not for me. Thanks.

Also, FYI, I have file watching explicitly disabled in cypress.json, but it’s still crashing:

{
  "baseUrl": "http://localhost:3003",
  "watchForFileChanges": false,
  "defaultCommandTimeout": 10000
}

It doesn’t make sense to put it in the config file, because you do want it to watch for changes while writing/debugging tests. The correct way is to pass an override through the CLI:

cypress run --config watchForFileChanges=false

See: https://docs.cypress.io/guides/guides/command-line#cypress-run-config-lt-config-gt