hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.36k stars 4.84k forks source link

hexo server crashes on every file change #1221

Closed hoschi closed 8 years ago

hoschi commented 9 years ago

Hi,

here is my test workflow:

test-hexo > hexo server --port 9778       
INFO  Hexo is running at http://0.0.0.0:9778/. Press Ctrl+C to stop.

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: EISDIR, read

I tried this with node versions 0.10.38 and 0.12.2. I don't know if this is important, but I get warnings during npm install, here is the log:

npm WARN optional dep failed, continuing fsevents@0.3.5

> dtrace-provider@0.4.0 install /home/hoschi/repos/test-hexo/node_modules/hexo/node_modules/bunyan/node_modules/dtrace-provider
> node scripts/install.js

npm WARN optional dep failed, continuing fsevents@0.3.5
hexo-renderer-ejs@0.1.0 node_modules/hexo-renderer-ejs
├── ejs@1.0.0
└── lodash@2.4.1

hexo-generator-archive@0.1.1 node_modules/hexo-generator-archive
├── object-assign@2.0.0
└── hexo-pagination@0.0.2 (utils-merge@1.0.0)

hexo-generator-index@0.1.0 node_modules/hexo-generator-index
├── object-assign@2.0.0
└── hexo-pagination@0.0.2 (utils-merge@1.0.0)

hexo-generator-tag@0.1.0 node_modules/hexo-generator-tag
├── object-assign@2.0.0
└── hexo-pagination@0.0.2 (utils-merge@1.0.0)

hexo-generator-category@0.1.1 node_modules/hexo-generator-category
├── object-assign@2.0.0
└── hexo-pagination@0.0.2 (utils-merge@1.0.0)

hexo-server@0.1.2 node_modules/hexo-server
├── object-assign@2.0.0
├── open@0.0.5
├── mime@1.3.4
├── bluebird@2.9.24
├── chalk@0.5.1 (ansi-styles@1.1.0, escape-string-regexp@1.0.3, supports-color@0.2.0, strip-ansi@0.3.0, has-ansi@0.1.0)
├── morgan@1.5.2 (basic-auth@1.0.0, depd@1.0.1, on-finished@2.2.0, debug@2.1.3)
├── compression@1.4.3 (on-headers@1.0.0, vary@1.0.0, bytes@1.0.0, debug@2.1.3, compressible@2.0.2, accepts@1.2.5)
├── serve-static@1.9.2 (utils-merge@1.0.0, escape-html@1.0.1, parseurl@1.3.0, send@0.12.2)
└── connect@3.3.5 (utils-merge@1.0.0, parseurl@1.3.0, finalhandler@0.3.4, debug@2.1.3)

hexo-renderer-marked@0.2.5 node_modules/hexo-renderer-marked
├── object-assign@2.0.0
├── marked@0.3.3
├── strip-indent@1.0.1 (get-stdin@4.0.1)
└── hexo-util@0.1.6 (ent@2.2.0, bluebird@2.9.24, highlight.js@8.5.0)

hexo-renderer-stylus@0.2.3 node_modules/hexo-renderer-stylus
├── stylus@0.50.0 (css-parse@1.7.0, mkdirp@0.3.5, debug@2.1.3, source-map@0.1.43, glob@3.2.11, sax@0.5.8)
└── nib@1.1.0 (stylus@0.49.3)

hexo@3.0.1 node_modules/hexo
├── hexo-front-matter@0.2.2
├── pretty-hrtime@1.0.0
├── abbrev@1.0.5
├── archy@1.0.0
├── titlecase@1.0.2
├── strip-indent@1.0.1 (get-stdin@4.0.1)
├── text-table@0.2.0
├── tildify@1.0.0 (user-home@1.1.1)
├── hexo-i18n@0.2.1 (sprintf-js@1.0.2)
├── chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3)
├── minimatch@2.0.4 (brace-expansion@1.1.0)
├── through2@1.1.1 (xtend@4.0.0, readable-stream@1.1.13)
├── hexo-fs@0.1.3 (escape-string-regexp@1.0.3, graceful-fs@3.0.6, chokidar@0.12.6)
├── bluebird@2.9.24
├── warehouse@1.0.2 (graceful-fs@3.0.6, cuid@1.2.4, JSONStream@0.10.0)
├── cheerio@0.19.0 (entities@1.1.1, dom-serializer@0.1.0, css-select@1.0.0, htmlparser2@3.8.2)
├── swig-extras@0.0.1 (markdown@0.5.0)
├── hexo-cli@0.1.4 (minimist@1.1.1)
├── moment@2.9.0
├── js-yaml@3.2.7 (argparse@1.0.2, esprima@2.0.0)
├── swig@1.4.2 (optimist@0.6.1, uglify-js@2.4.20)
├── lodash@3.7.0
├── moment-timezone@0.3.1
├── hexo-util@0.1.6 (ent@2.2.0, highlight.js@8.5.0)
├── nunjucks@1.3.3 (optimist@0.6.1, chokidar@0.12.6)
└── bunyan@1.3.5 (safe-json-stringify@1.0.3, mv@2.0.3, dtrace-provider@0.4.0)
Chaosed0 commented 9 years ago

Exact same problem here. Arch Linux x64.

DocLabyrinth commented 9 years ago

I have the same issue, but it only appears when I use vim to edit the markdown files. Editing and saving using mousepad doesn't produce the same behaviour. I've seen similar problems with other node apps which watch files for changes. I suspect that Emacs will also be affected, which editor are you using when the issue appears?

Vim writes to a swap file then either renames or switches it out with the actual file when you save it, I couldn't find exact details in the docs. The way it does this confuses or conflicts with many file watching systems in different languages. This was the most similar issue in a javascript project that I could find: https://github.com/arboleya/coffee-toaster/issues/47

I suspect that one of the dependencies which does the file monitoring is either mishandling the file system events produced by the vim save sequence, or the handlers in hexo aren't accounting for this situation (the first is most likely given the E_ISDIR error)

Chaosed0 commented 9 years ago

I was indeed using Vim at the time. That explanation makes sense.

rorsach commented 9 years ago

I get this error and I am using emacs.

marrone commented 9 years ago

I was having the same issue, editing with Vim on linux.

It looks like hexo-fs's dependencies list chokidar at a very outdated version (0.12). Chokidar is what is responsible for watching the file system and the latest version is 1.0.5.

Not ideal, but I manually bumped the version to 1.0.5 in hexo-fs's package.json and re-installed the module and now watching files works fine without errors.

walkingice commented 9 years ago

I followed marrone's suggestion to upgrade chokidar version, and that does fix the problem.

inhji commented 9 years ago

For the sake of completeness, this also happens when using Github's Atom Editor with the Option Back Up Before Saving enabled.

leesei commented 8 years ago

chokidar was updated back in April. https://github.com/hexojs/hexo-fs/commit/ec8b2527ec1f25bc9e41ebff160f550950997753