EMFILE exception when watching on Win7
- Dominant language
- JavaScript
- Stars
- 81
- Forks
- 55
- PR merge metrics
- No merged PRs in 30d
Description
On my Window 7 system, the "hexo server" command will usually crash with the EMFILE error. I say usually because if I run "hexo clean && hexo server" enough times then it eventually works. Below is my cmd shell dump...
> C:\Users\andjon\Source\janderland>hexo server --debug
> 02:16:47.479 DEBUG Hexo version: 3.2.0
> 02:16:47.479 DEBUG Working directory: ~\Source\janderland\
> 02:16:47.572 DEBUG Config loaded: ~\Source\janderland_config.yml
> 02:16:47.588 DEBUG Plugin loaded: hexo-renderer-marked
> 02:16:47.588 DEBUG Plugin loaded: hexo-generator-index
> 02:16:47.588 DEBUG Plugin loaded: hexo-generator-archive
> 02:16:47.588 DEBUG Plugin loaded: hexo-renderer-ejs
> 02:16:47.603 DEBUG Plugin loaded: hexo-generator-category
> 02:16:47.603 DEBUG Plugin loaded: hexo-generator-tag
> 02:16:47.635 DEBUG Plugin loaded: hexo-server
> 02:16:47.650 DEBUG Loading database.
> 02:16:47.650 INFO Start processing
> 02:16:48.430 DEBUG Theme config loaded.
> 02:16:48.430 DEBUG Processed: _config.yml
> 02:16:48.430 DEBUG Processed: source/css/foundation-icons.css
> 02:16:48.430 DEBUG Processed: source/css/foundation-icons.eot
> 02:16:48.446 DEBUG Processed: source/css/foundation-icons.ttf
> 02:16:48.446 DEBUG Processed: source/css/foundation-icons.woff
> 02:16:48.446 DEBUG Processed: source/css/jander.css
> 02:16:48.446 DEBUG Processed: source/js/index.js
> 02:16:48.446 DEBUG Processed: source/js/app.js
> 02:16:48.539 DEBUG Processed: layout/index.ejs
> 02:16:48.539 DEBUG Processed: layout/layout.ejs
> 02:16:48.555 DEBUG Processed: source/css/foundation.css
> 02:16:48.851 DEBUG Processed: layout/post.ejs
> 02:16:48.851 DEBUG Processed: source/css/foundation-icons.svg
> 02:16:48.961 DEBUG Processed: layout/_partials/css.ejs
> 02:16:48.961 DEBUG Processed: layout/_partials/js.ejs
> 02:16:48.961 DEBUG Processed: layout/_partials/list_posts.ejs
> 02:16:48.961 DEBUG Processed: _posts/Test.md
> 02:16:48.961 DEBUG Processed: _posts/This-is-a-dummy-post.md
> 02:16:48.961 DEBUG Processed: _posts/Heyo.md
> 02:16:48.961 DEBUG Processed: _posts/What-up-punks.md
> fs.js:584
> return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
> ^
>
> Error: EMFILE: too many open files, open 'C:\Users\andjon\Source\janderland\node_modules\readdirp\stream-api.js'
> at Error (native)
> at Object.fs.openSync (fs.js:584:18)
> at Object.fs.readFileSync (fs.js:431:33)
> at Object.Module._extensions..js (module.js:421:20)
> at Module.load (module.js:357:32)
> at Function.Module._load (module.js:314:12)
> at Module.require (module.js:367:17)
> at require (internal/module.js:16:19)
> at readdir (C:\Users\andjon\Source\janderland\node_modules\readdirp\readdirp.js:52:25)
> at FSWatcher. (C:\Users\andjon\Source\janderland\node_modules\chokidar\lib\nodefs-handler.js:355:5)
> at FSWatcher.NodeFsHandler._handleDir (C:\Users\andjon\Source\janderland\node_modules\chokidar\lib\nodefs-handler.js:406:18)
> at FSWatcher. (C:\Users\andjon\Source\janderland\node_modules\chokidar\lib\nodefs-handler.js:455:19)
> at FSWatcher. (C:\Users\andjon\Source\janderland\node_modules\chokidar\lib\nodefs-handler.js:460:16)
> at FSReqWrap.oncomplete (fs.js:82:15)
I tested the exact same hexo site on my Macbook and an EMFILE error is never thrown.
Notice that the EMFILE error actually occur's during a require() call by the readdirp module. One possible solution could be to 'gracefulify' the fs module during the hexo-fs module's initialization...
`var fs = require('graceful-fs');
var nodeFs = require('fs');
fs.gracefulify(nodeFs);`
... though I haven't tested the effects this would have on performance.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.