Skip to content
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

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

Closed
jakub-bao opened this issue Apr 7, 2020 · 18 comments

Comments

@jakub-bao
Copy link

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.

@jakub-bao jakub-bao changed the title Cypress crashing on Lunux > System limit for number of file watchers reached 'package.json' Cypress crashing on Linux > System limit for number of file watchers reached 'package.json' Apr 7, 2020
@jennifer-shehane
Copy link
Member

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

@jakub-bao
Copy link
Author

@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.

@jakub-bao
Copy link
Author

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

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

@berviantoleo
Copy link

berviantoleo commented Jul 8, 2021

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

@ckxddd0324
Copy link

Can we reopen this or do we create a separate issue for this? I am seeing in my project with this issue as well.

@sterling
Copy link

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

@adi518
Copy link

adi518 commented Jul 21, 2021

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

@Asharma86
Copy link

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.

@Asharma86
Copy link

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

@adi518
Copy link

adi518 commented Jul 21, 2021

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.

@elevatebart
Copy link
Contributor

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

@Hunsu
Copy link

Hunsu commented Sep 25, 2021

I ran into this recently and I would like to share how I fixed the issue. If you customize the webpack config then you should make sur to disable the watch feature of dev server. The watch feature is enabled by default in development mode.

So I added an environment variable to tell if cypress is running on CI or not. In my case I also configured webpack to use polling. The config will depend on the version of webpack you are using.

@wereHamster
Copy link

@Hunsu can you share your config?

@jorian-p
Copy link

jorian-p commented Sep 6, 2022

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: cypress-io/github-action#317 (comment)

@cuongld2
Copy link

Thanks @jorian-p .
This works like a charm.

@adi518
Copy link

adi518 commented Dec 23, 2022

But using polling is inferior to fs events.

@mat813
Copy link

mat813 commented Jan 1, 2023

So, I ran into this upgrading from 11.2 to 12.2.

We're using GitLab, so I added this to the configuration, which disables watching when inside CI:

  watchForFileChanges: process.env.CI_PROJECT_URL == null,

@fer-ri
Copy link

fer-ri commented Mar 11, 2024

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: cypress-io/github-action#317 (comment)

Works for me on Ubuntu + cypress/included:13.6.6

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests