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

Error: EMFILE: too many open files #1126

Closed
jcimoch opened this issue Sep 26, 2016 · 5 comments
Closed

Error: EMFILE: too many open files #1126

jcimoch opened this issue Sep 26, 2016 · 5 comments

Comments

@jcimoch
Copy link

jcimoch commented Sep 26, 2016

  • A brief description
    I was trying to start my project which was previously developed under OSX system. I cloned my git repository and tryied to run it under new windows subsytem for linux. Unfortunatelly it won't work out of the box.
  • Expected results
hexo serve
Hexo is running at http://localhost:4000/
  • Actual results (with terminal output if applicable)
INFO  Start processing
fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: EMFILE: too many open files, open '/mnt/c/Users/jcimoch/Desktop/blog/node_modules/readdirp/stream-api.js'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.readFileSync (fs.js:508:33)
    at Object.Module._extensions..js (module.js:564:20)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at readdir (/mnt/c/Users/jcimoch/Desktop/blog/node_modules/readdirp/readdirp.js:55:48)
    at FSWatcher.<anonymous> (/mnt/c/Users/jcimoch/Desktop/blog/node_modules/chokidar/lib/nodefs-handler.js:355:5)
    at FSWatcher.NodeFsHandler._handleDir (/mnt/c/Users/jcimoch/Desktop/blog/node_modules/chokidar/lib/nodefs-handler.js:406:18)
    at FSWatcher.<anonymous> (/mnt/c/Users/jcimoch/Desktop/blog/node_modules/chokidar/lib/nodefs-handler.js:455:19)
    at FSWatcher.<anonymous> (/mnt/c/Users/jcimoch/Desktop/blog/node_modules/chokidar/lib/nodefs-handler.js:460:16)
    at FSReqWrap.oncomplete (fs.js:123:15)
  • Your Windows build number
    Windows 10 Pro N 64-bit (10.0, Build 14393) (14393.rs1_release_inmarket.160906-1818)
  • Steps / All commands required to reproduce the error from a brand new installation
    npm install hexo-cli -g
    hexo init blog
    cd blog
    npm install
    hexo server

  • Required packages and commands to install
node.js, npm, hexo.js

My node.js version is 6.6.0

All the same commands and packages versions works fine under OSX or native Linux.
I think that might be related to windows bash implementation, because it works without problems on other UNIX like systems.

@aseering
Copy link
Contributor

Hi @jcimoch -- thanks for reporting this! In my experience, nodejs is very good at using up lots of file descriptors, which can lead to EMFILE. You say that this works on a Mac and on an Ubuntu Linux machine; could you try running the following command on those two machines?: (In the same shell as you are launching your application.)

ulimit -n

That will print out the maximum number of files that an application launched in that shell is allowed to open. I'm wondering if someone or something might have raised those limits in your other environments.

@jcimoch
Copy link
Author

jcimoch commented Sep 26, 2016

It is 256 on OSX. I don't have access to ubuntu right now but i assume same or bigger limit.
Windows bash shell tells me that 2048 is the limit. Strange.

@benhillis
Copy link
Member

benhillis commented Sep 26, 2016

@jcimoch It might be interesting to look at your process in /proc/[pid]/fd to see how many file descriptors are open and what they are. I suspect there might be some other call in your project that is failing and leaking file descriptors (maybe due to an earlier failure in WSL).

For example:

ben@BENHILL-Z420:/proc/19/fd$ ls -alF
total 0
dr-x------ 1 ben ben 0 Sep 26 08:51 ./
dr-xr-xr-x 1 ben ben 0 Sep 26 08:51 ../
lrwx------ 1 ben ben 0 Sep 26 08:51 0 -> /dev/tty1
lrwx------ 1 ben ben 0 Sep 26 08:51 1 -> /dev/tty1
lrwx------ 1 ben ben 0 Sep 26 08:51 2 -> /dev/tty1
lrwx------ 1 ben ben 0 Sep 26 08:51 255 -> /dev/tty1

@jcimoch
Copy link
Author

jcimoch commented Sep 26, 2016

It seems it is well known issue https://hexo.io/docs/troubleshooting.html#EMFILE-Error. I have also tested it with native windows node.js instalation and there is the same problem. So it is not connected to windows bash but more like system IO.

@benhillis
Copy link
Member

Marking as a duplicate of #1688 which will be fixed in Insider builds soon.

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

No branches or pull requests

3 participants