cypress: Cypress v3.3.0 crashes with ENOSPC in AWS CodeBuild

Current behavior:

[AWS CodeBuild Plugin] > cross-env NODE_ENV=test cypress run
[AWS CodeBuild Plugin] 
[AWS CodeBuild Plugin] { Error: watch /codebuild/output/src525851951/src/project/cypress/plugins/index.js ENOSPC
[AWS CodeBuild Plugin]     at _errnoException (util.js:1024:11)
[AWS CodeBuild Plugin]     at FSWatcher.start (fs.js:1386:19)
[AWS CodeBuild Plugin]     at Object.fs.watch (fs.js:1412:11)
[AWS CodeBuild Plugin]     at createFsWatchInstance (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:37:15)
[AWS CodeBuild Plugin]     at setFsWatchListener (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:80:15)
[AWS CodeBuild Plugin]     at FSWatcher.NodeFsHandler._watchWithNodeFs (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:228:14)
[AWS CodeBuild Plugin]     at FSWatcher.NodeFsHandler._handleFile (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:255:21)
[AWS CodeBuild Plugin]     at FSWatcher.<anonymous> (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:473:21)
[AWS CodeBuild Plugin]     at /root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/graceful-fs/polyfills.js:285:20
[AWS CodeBuild Plugin]     at FSReqWrap.oncomplete (fs.js:153:5)
[AWS CodeBuild Plugin] 
[AWS CodeBuild Plugin]   code: 'ENOSPC',
[AWS CodeBuild Plugin]   errno: 'ENOSPC',
[AWS CodeBuild Plugin]   syscall: 'watch /codebuild/output/src525851951/src/project/cypress/plugins/index.js',
[AWS CodeBuild Plugin]   filename: '/codebuild/output/src525851951/src/project/cypress/plugins/index.js' }
[AWS CodeBuild Plugin] Error: watch /codebuild/output/src525851951/src/project/cypress/plugins/index.js ENOSPC
[AWS CodeBuild Plugin]     at _errnoException (util.js:1024:11)
[AWS CodeBuild Plugin]     at FSWatcher.start (fs.js:1386:19)
[AWS CodeBuild Plugin]     at Object.fs.watch (fs.js:1412:11)
[AWS CodeBuild Plugin]     at createFsWatchInstance (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:37:15)
[AWS CodeBuild Plugin]     at setFsWatchListener (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:80:15)
[AWS CodeBuild Plugin]     at FSWatcher.NodeFsHandler._watchWithNodeFs (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:228:14)
[AWS CodeBuild Plugin]     at FSWatcher.NodeFsHandler._handleFile (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:255:21)
[AWS CodeBuild Plugin]     at FSWatcher.<anonymous> (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:473:21)
[AWS CodeBuild Plugin]     at /root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/graceful-fs/polyfills.js:285:20
[AWS CodeBuild Plugin]     at FSReqWrap.oncomplete (fs.js:153:5)
[AWS CodeBuild Plugin] 
[AWS CodeBuild Plugin] { Error: watch /codebuild/output/src525851951/src/project/env/parse.js ENOSPC
[AWS CodeBuild Plugin]     at _errnoException (util.js:1024:11)
[AWS CodeBuild Plugin]     at FSWatcher.start (fs.js:1386:19)
[AWS CodeBuild Plugin]     at Object.fs.watch (fs.js:1412:11)
[AWS CodeBuild Plugin]     at createFsWatchInstance (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:37:15)
[AWS CodeBuild Plugin]     at setFsWatchListener (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:80:15)
[AWS CodeBuild Plugin]     at FSWatcher.NodeFsHandler._watchWithNodeFs (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:228:14)
[AWS CodeBuild Plugin]     at FSWatcher.NodeFsHandler._handleFile (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:255:21)
[AWS CodeBuild Plugin]     at FSWatcher.<anonymous> (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:473:21)
[AWS CodeBuild Plugin]     at /root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/graceful-fs/polyfills.js:285:20
[AWS CodeBuild Plugin]     at FSReqWrap.oncomplete (fs.js:153:5)
[AWS CodeBuild Plugin] 
[AWS CodeBuild Plugin]   code: 'ENOSPC',
[AWS CodeBuild Plugin]   errno: 'ENOSPC',
[AWS CodeBuild Plugin]   syscall: 'watch /codebuild/output/src525851951/src/project/env/parse.js',
[AWS CodeBuild Plugin]   filename: '/codebuild/output/src525851951/src/project/env/parse.js' }
[AWS CodeBuild Plugin] Error: watch /codebuild/output/src525851951/src/project/env/parse.js ENOSPC
[AWS CodeBuild Plugin]     at _errnoException (util.js:1024:11)
[AWS CodeBuild Plugin]     at FSWatcher.start (fs.js:1386:19)
[AWS CodeBuild Plugin]     at Object.fs.watch (fs.js:1412:11)
[AWS CodeBuild Plugin]     at createFsWatchInstance (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:37:15)
[AWS CodeBuild Plugin]     at setFsWatchListener (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:80:15)
[AWS CodeBuild Plugin]     at FSWatcher.NodeFsHandler._watchWithNodeFs (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:228:14)
[AWS CodeBuild Plugin]     at FSWatcher.NodeFsHandler._handleFile (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:255:21)
[AWS CodeBuild Plugin]     at FSWatcher.<anonymous> (/root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/chokidar/lib/nodefs-handler.js:473:21)
[AWS CodeBuild Plugin]     at /root/.cache/Cypress/3.3.0/Cypress/resources/app/packages/server/node_modules/graceful-fs/polyfills.js:285:20
[AWS CodeBuild Plugin]     at FSReqWrap.oncomplete (fs.js:153:5)
[AWS CodeBuild Plugin] 

Desired behavior:

Cypress should run normally.

With version 3.2.0 same configuration this does not happens

Steps to reproduce: (app code and test code)

Use AWS Codebuild with NodeJS image, install Cypress 3.3.0 in it and try to run tests, it will fail

Versions

AWS Codebuild, Node 10.15.1, Yarn 1.13.0, Cypress 3.3.0

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 20 (7 by maintainers)

Most upvoted comments

Fo those who are struggling with this issue on AWS Codebuild, enabling privileged mode on the build allows to modify sysctl parameters, including fs.inotify.max_user_watches:

[Container] 2019/07/11 06:18:34 Running command sysctl fs.inotify.max_user_watches 
fs.inotify.max_user_watches = 8192 
 
[Container] 2019/07/11 06:18:34 Running command sysctl fs.inotify.max_user_watches=524288 
fs.inotify.max_user_watches = 524288 
 
[Container] 2019/07/11 06:18:34 Running command sysctl fs.inotify.max_user_watches 
fs.inotify.max_user_watches = 524288

FYI, in my case, I found this issue on GitLab CI/CD using cypress/base:8. I fixed by executing sysctl -w fs.inotify.max_user_watches=524288 before running the test. If anyone like to workaround this issue before the fix release, you might wanna try sysctl -w fs.inotify.max_user_watches=524288

I think the best solution here is to not register the file watchers when using cypress run what do you think @jennifer-shehane ?

I’m facing this issue. I’m using version 3.4.1.

I have met this issue on Ubuntu 18.04. This solved the issue:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Does anyone in this thread use any Cypress plugins or have requires in their Cypress plugins file? It may be part of the cause of this issue.


EDIT: I was able to repro the issue in the OP by doing sudo sysctl -w fs.inotify.max_user_watches=0 locally and then trying to run a Cypress project with a pluginsFile. The fix in #4458 makes it work again by not trying to watch the pluginsFile.

I think this should fix it from Cypress’s end, all file watching is disabled with this PR.

Users might still run in to this issue if they have other programs like webpack watching files, or if they manually watch files in their plugins file, but there’s not much we can do about that.

I’m glad I found this issue, thanks @luneo7. Having the same problem with Gitlab CI/CD and cypress 3.3.1.

Thus, I’m gonna keep 3.2.0 for a little longer 😄 !

Yeah… the change #4038 made chokidar use FS events, before it was using polling, so that increased the number of user_watches and made it boom.

It would be nice to have a way to make it use polling by passing a param so we can circumvent this fs.inotify.max_user_watches error in docker containers, or even a way to not need this file watch when running inside a CI, cause the files won’t change.