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

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

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

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

michaeldye opened this issue Feb 10, 2015 · 18 comments
Labels
bug

Comments

@michaeldye
Copy link

@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
Copy link

@acthp acthp commented Feb 14, 2015

Also have this issue. It's unusable.

@bloodyowl
Copy link

@bloodyowl bloodyowl commented Feb 17, 2015

👍

@pikeas
Copy link

@pikeas pikeas commented Feb 23, 2015

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

@michaeldye
Copy link
Author

@michaeldye michaeldye commented Feb 24, 2015

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

@pikeas
Copy link

@pikeas 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
Copy link

@virajsanghvi 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
Copy link

@virajsanghvi 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
Copy link

@acthp acthp commented Mar 12, 2015

Can you post more details? I need a workaround.

@virajsanghvi
Copy link

@virajsanghvi 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
Copy link

@ghost ghost commented Apr 23, 2015

This really makes it completely unusable for me :-/

@ghost
Copy link

@ghost 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
Copy link

@acthp 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
Copy link
Member

@jhnns jhnns commented Apr 28, 2015

I'm glad you have found a fix :)

@jhnns jhnns closed this Apr 28, 2015
@jhnns
Copy link
Member

@jhnns jhnns commented Apr 28, 2015

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

@gaogao1030
Copy link

@gaogao1030 gaogao1030 commented Nov 19, 2015

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

rjz added a commit to rjz/dotfiles that referenced this issue Feb 18, 2016
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
Copy link

@pizza2code 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
Copy link
Member

@jhnns 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
Copy link

@aethant 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
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
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
Some strange interaction between the way Vim saves by default, and how
webpack listens for file changes. See webpack/webpack#781 (comment)
nixpulvis added a commit to nixpulvis/dotfiles that referenced this issue Oct 16, 2018
Some strange interaction between the way Vim saves by default, and how
webpack listens for file changes. See webpack/webpack#781 (comment)
sauloperez added a commit to sauloperez/dotfiles that referenced this issue May 1, 2020
This overrides the default `auto` setting. This is needed to avoid
potential issues with webpack. Read more:

* https://webpack.js.org/guides/development/#adjusting-your-text-editor
* webpack/webpack#781 (comment)
* middleman/middleman-livereload#17 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
10 participants
You can’t perform that action at this time.