webpack-dev-server misses most Vim write events

When writing (:w) files in Vim on Linux, chokidar‘s example script produces events like this:

RawEvent: change Quota.js { watchedPath: '/project/app/modules' }
change /project/app/modules/Quota.js

… inotify in Linux reports the event this way:

CLOSE_NOWRITE,CLOSE on /project/app/modules/Quota.js at 1423591700

Unfortunately, almost every file update is missed by an idle webpack-dev-server instance (webpack-dev-server --watch --hot --inline). It seems the first write is reliably detected and only sporadic others are.

I’m using chokidar@1.0.0-rc3 <- watchpack@0.2.3 <- webpack@1.5.3

See also paulmillr/chokidar#226

Author: Fantashit

2 thoughts on “webpack-dev-server misses most Vim write events

  1. Found the problem:
    You have to tell vim how it should save the file. On most systems it is set to “auto” letting vim decide the saving strategy. Sometimes it writes directly to the file, sometimes it renames the old file and write a new one. The latter one causes watching problems.

    Simple set “:set backupcopy=yes” in vim and it works perfectly!

    See: http://vimdoc.sourceforge.net/htmldoc/options.html#'backupcopy

  2. @jhnns Should this have been closed? It’s unusual that changing our source editor’s file-saving method would be considered a fix, rather than a workaround for an existing issue. All other file watchers I’ve used (gulp.watch() and watchify) function fine without changing the behavior of my file editors.

Comments are closed.