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

webpack-dev-server misses most Vim write events #781

Closed
michaeldye opened this Issue Feb 10, 2015 · 18 comments

Comments

Projects
None yet
@michaeldye

michaeldye commented Feb 10, 2015

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

@acthp

This comment has been minimized.

Show comment
Hide comment
@acthp

acthp Feb 14, 2015

Also have this issue. It's unusable.

acthp commented Feb 14, 2015

Also have this issue. It's unusable.

@bloodyowl

This comment has been minimized.

Show comment
Hide comment
@bloodyowl

bloodyowl commented Feb 17, 2015

👍

@pikeas

This comment has been minimized.

Show comment
Hide comment
@pikeas

pikeas Feb 23, 2015

Is this related to #793 (comment)? The OS-level fix suggested there might help.

pikeas commented Feb 23, 2015

Is this related to #793 (comment)? The OS-level fix suggested there might help.

@michaeldye

This comment has been minimized.

Show comment
Hide comment
@michaeldye

michaeldye Feb 24, 2015

@pikeas Doesn't seem related to me, we're using different OSes with different filesystems.

michaeldye commented Feb 24, 2015

@pikeas Doesn't seem related to me, we're using different OSes with different filesystems.

@pikeas

This comment has been minimized.

Show comment
Hide comment
@pikeas

pikeas Feb 24, 2015

@michaeldye Gotcha. I thought it might have been a Linux system running in a Vagrant VM (eg, code dir loaded in as a volume).

pikeas commented Feb 24, 2015

@michaeldye Gotcha. I thought it might have been a Linux system running in a Vagrant VM (eg, code dir loaded in as a volume).

@sokra sokra added the bug label Feb 25, 2015

@virajsanghvi

This comment has been minimized.

Show comment
Hide comment
@virajsanghvi

virajsanghvi Mar 10, 2015

Just wanted to mention that this happens with --watch as well as the dev server.

Does anyone have any workarounds?

virajsanghvi commented Mar 10, 2015

Just wanted to mention that this happens with --watch as well as the dev server.

Does anyone have any workarounds?

@virajsanghvi

This comment has been minimized.

Show comment
Hide comment
@virajsanghvi

virajsanghvi Mar 12, 2015

Thought I would mention that using OldWatchingPlugin actually solved my issues with watching vim file changes (not using the dev-server).

virajsanghvi commented Mar 12, 2015

Thought I would mention that using OldWatchingPlugin actually solved my issues with watching vim file changes (not using the dev-server).

@acthp

This comment has been minimized.

Show comment
Hide comment
@acthp

acthp Mar 12, 2015

Can you post more details? I need a workaround.

acthp commented Mar 12, 2015

Can you post more details? I need a workaround.

@virajsanghvi

This comment has been minimized.

Show comment
Hide comment
@virajsanghvi

virajsanghvi Mar 12, 2015

I just added the plugin to my webpack.config.js:

plugins: [
  ...
  new webpack.OldWatchingPlugin(),
  ...
],

According to #125, OldWatchingPlugin should theoretically be giving me issues, but, at least for webpack 1.6, I haven't had any issues with it in comparison to NewWatchingPlugin (which is now the default), which effectively broke watching (for me). Anyways, YMMV.

virajsanghvi commented Mar 12, 2015

I just added the plugin to my webpack.config.js:

plugins: [
  ...
  new webpack.OldWatchingPlugin(),
  ...
],

According to #125, OldWatchingPlugin should theoretically be giving me issues, but, at least for webpack 1.6, I haven't had any issues with it in comparison to NewWatchingPlugin (which is now the default), which effectively broke watching (for me). Anyways, YMMV.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Apr 23, 2015

This really makes it completely unusable for me :-/

ghost commented Apr 23, 2015

This really makes it completely unusable for me :-/

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Apr 23, 2015

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'

ghost commented Apr 23, 2015

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'

@acthp

This comment has been minimized.

Show comment
Hide comment
@acthp

acthp Apr 28, 2015

@wingedkiwi Thank you so much! Working perfectly now.

This really should be a vim faq thing: using vim with a file watcher. Seems like this issue could be closed, or maybe a brief note added to the watcher docs, to warn other vim users.

acthp commented Apr 28, 2015

@wingedkiwi Thank you so much! Working perfectly now.

This really should be a vim faq thing: using vim with a file watcher. Seems like this issue could be closed, or maybe a brief note added to the watcher docs, to warn other vim users.

@jhnns

This comment has been minimized.

Show comment
Hide comment
@jhnns

jhnns Apr 28, 2015

Member

I'm glad you have found a fix :)

Member

jhnns commented Apr 28, 2015

I'm glad you have found a fix :)

@jhnns jhnns closed this Apr 28, 2015

@jhnns

This comment has been minimized.

Show comment
Hide comment
@jhnns

jhnns Apr 28, 2015

Member

The docs are editable. So if you want to give your VIM colleagues a hint, go for it 👍

Member

jhnns commented Apr 28, 2015

The docs are editable. So if you want to give your VIM colleagues a hint, go for it 👍

@gaogao1030

This comment has been minimized.

Show comment
Hide comment
@gaogao1030

gaogao1030 Nov 19, 2015

@wingedkiwi Thank you ありかとう ございました 非常感谢

gaogao1030 commented Nov 19, 2015

@wingedkiwi Thank you ありかとう ございました 非常感谢

rjz added a commit to rjz/dotfiles that referenced this issue Feb 18, 2016

Force vim backup settings
Force vim's backup strategy to play nicely-ish with filesystem watch
tasks. See: webpack/webpack#781

ags added a commit to ags/dotfiles that referenced this issue May 5, 2016

@pizza2code

This comment has been minimized.

Show comment
Hide comment
@pizza2code

pizza2code Jun 29, 2016

@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.

pizza2code commented Jun 29, 2016

@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.

@jhnns

This comment has been minimized.

Show comment
Hide comment
@jhnns

jhnns Jun 30, 2016

Member

I can re-open it, but we need a champion for this from the VI community, otherwise nothing will happen. Every editor I know works like expected. Do you want to contribute @pizza2code?

Member

jhnns commented Jun 30, 2016

I can re-open it, but we need a champion for this from the VI community, otherwise nothing will happen. Every editor I know works like expected. Do you want to contribute @pizza2code?

@aethant

This comment has been minimized.

Show comment
Hide comment
@aethant

aethant Jul 24, 2016

I've tried applying the workaround mentioned here in vim :set backupcopy=yes (vim 7.4.1755) on Mac OS X 10.10.5 (Yosemite) and I get maybe 3-4 (usually 1) saves before Webpack stops responding. Atom does save and get Webpack to respond, but not after I've opened the same file in vim. I have to restart Webpack to get it working. I'm also using Webpack inside a Docker container in this instance.

Anyone have any ideas why in this case the workaround does work?

aethant commented Jul 24, 2016

I've tried applying the workaround mentioned here in vim :set backupcopy=yes (vim 7.4.1755) on Mac OS X 10.10.5 (Yosemite) and I get maybe 3-4 (usually 1) saves before Webpack stops responding. Atom does save and get Webpack to respond, but not after I've opened the same file in vim. I have to restart Webpack to get it working. I'm also using Webpack inside a Docker container in this instance.

Anyone have any ideas why in this case the workaround does work?

oligot pushed a commit to oligot/jspm-dev-builder-cli that referenced this issue Aug 4, 2016

Olivier Ligot
Switch back to chokidar
watchman is still alpha on Windows and the problem I had with Vim
can be solved by using
set backupcopy=yes
as described in this issue
webpack/webpack#781 (comment)

davidyorr added a commit to davidyorr/dotfiles that referenced this issue Apr 4, 2017

Change vim backup
I was having problems running webpack when I'd save a file and I'd get a
file not found error. This seems to have fixed it, but I'm not sure if
I'm supposed to keep the backup setting too.

webpack/webpack#781 (comment)

mleue added a commit to mleue/dotfiles that referenced this issue Apr 22, 2018

nixpulvis added a commit to nixpulvis/dotfiles that referenced this issue Sep 8, 2018

Fix for Webpack + Vim.
Some strange interaction between the way Vim saves by default, and how
webpack listens for file changes. See webpack/webpack#781 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment