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

yarn start / npm start / reac-static start errors with 'Error: watch /home/mrh/src/safe-sites/safe-dweb-blog/static.config.js ENOSPC' #952

Closed
happybeing opened this issue Jan 8, 2019 · 9 comments
Labels
enhancement 🦄 Changing current behaviour, enhancing what's already there

Comments

@happybeing
Copy link

Are you reporting a bug?

Kind of

Environment

    react-static -V: 6.1.5
    node -v: 8.11.3
    npm -v: 6.4.1
    Operating system: Ubuntu 18.10
    Browser and version (if relevant):

Steps to Reproduce the problem

create a new project with react-static create and use the 'basic' template
cd into the project and type yarn start, or npm start, or react-static start. Note that yarn build and yarn serve behave as expected. Result for yarn start is as follows:

$ yarn start
yarn run v1.7.0
$ react-static start
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: watch /home/mrh/src/safe-sites/safe-dweb-blog/static.config.js ENOSPC
    at _errnoException (util.js:992:11)
    at FSWatcher.start (fs.js:1382:19)
    at Object.fs.watch (fs.js:1408:11)
    at createFsWatchInstance (/home/mrh/src/safe-sites/safe-dweb-blog/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/home/mrh/src/safe-sites/safe-dweb-blog/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/mrh/src/safe-sites/safe-dweb-blog/node_modules/chokidar/lib/nodefs-handler.js:232:14)
    at FSWatcher.NodeFsHandler._handleFile (/home/mrh/src/safe-sites/safe-dweb-blog/node_modules/chokidar/lib/nodefs-handler.js:259:21)
    at FSWatcher.<anonymous> (/home/mrh/src/safe-sites/safe-dweb-blog/node_modules/chokidar/lib/nodefs-handler.js:480:21)
    at FSReqWrap.oncomplete (fs.js:153:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected Behavior

yarn start
yarn run v1.7.0
$ react-static start
=> Building Routes...
=> [✓] Routes Built (0.5s)
=> Building Templates
=> [✓] Templates Built
=> Building App Bundle...
=> [✓] Build Complete (5.8s)
=> [✓] App serving at http://localhost:3000
=> File changed: /tmp/dev-server/index.html
=> Updating build...
=> [✓] Build Updated (0.4s)
=> File changed: /src/App.js
=> Updating build...
=> [✓] Build Updated (0.5s)

Solution

The problem appears to be due to the number of files being watched hitting a limit, which can be increased by the following command:

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

After running that, yarn start should behave as expected.

I don't know why I hit this while others presumably have not yet, as @tannerlinsley hasn't seen this before. I found the solution in this issue comment.

@tannerlinsley tannerlinsley added the enhancement 🦄 Changing current behaviour, enhancing what's already there label Jan 8, 2019
@tannerlinsley
Copy link
Contributor

If you post a link to your repo, we may be able to debug this, but I think I would classify this as extreme edge case. As long as you were able to get around it for now, let's plan on debugging it soon and going forward with your fix. The amount of files to be watched should not be large at all, not even hundreds (for a large site).

Marking this with enhancement, given it's very edge case.

@happybeing
Copy link
Author

happybeing commented Jan 8, 2019 via email

@tannerlinsley
Copy link
Contributor

Would you be open to editing some source files in your local React Static to help us nail down the issue?

@happybeing
Copy link
Author

happybeing commented Jan 8, 2019 via email

@tannerlinsley
Copy link
Contributor

tannerlinsley commented Jan 8, 2019 via email

@happybeing
Copy link
Author

Hmm, well to update:

  • I don't see anything odd in the contents of my 'basic' project (175M of files in node_modules but that's not unusual)
  • I had a hunch that maybe I have so many files under projects in Atom that this was putting me close to the watch limit, but even having reverted the fs.inotify.max_user_watches solution, I can no longer trigger this error.

So the issue is probably to do with my system state. Maybe Atom active project files, maybe not, but until I can reproduce it I guess we should wait and then I'll revisit.

@Pixelatex
Copy link
Collaborator

You can just create your app outside of atom with terminal and see if atom is indeed the culprit here.

@happybeing
Copy link
Author

You can just create your app outside of atom with terminal and see if atom is indeed the culprit here.
Indeed, unfortunately the problem has gone away so I can't do this until it comes back.

@happybeing
Copy link
Author

I can confirm the cause in my case is having lots of files under projects open in Atom. This must have pushed the fs watch near or past its limit, so that when I manually set this (as described under Solution in the OP) the error goes away.

Undoing that setting didn't take effect until a system restart, so I was only able to verify this today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🦄 Changing current behaviour, enhancing what's already there
Projects
None yet
Development

No branches or pull requests

3 participants