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

Vim + presence of package.json results in watchify breakage #206

Closed
rashkov opened this issue Apr 16, 2015 · 4 comments
Closed

Vim + presence of package.json results in watchify breakage #206

rashkov opened this issue Apr 16, 2015 · 4 comments

Comments

@rashkov
Copy link

rashkov commented Apr 16, 2015

Watchify seems to stop watching files when they are edited in Vim. This problem goes away when package.json is removed.

A couple of thoughts on this:
1)Since browserify and maybe watchify parse package.json before running, this may be some kind of race condition.
2) I am not seeing this problem when using Chokidar.watch directly on a file.
3) Vim seems to do what's called a "safe write" where it writes the file all at once. This might explain why other editors, or simply touching the file doesn't trigger this issue.
4) Using the Watchify API directly with Gulp also shows this issue.

At this point I'm completely out of ideas. Would love a fresh perspective on this issue.

I spun up a fresh Debian instance and logged my tests below. Added some line-breaks for readability:

Linux frankfurter 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u1 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Apr 16 15:22:31 2015 from 38.100.174.226

root@frankfurter:~# ls
a.js  b.js  node  node_modules  node-v0.12.2-linux-x64  npm  package.json


root@frankfurter:~# ./node -v
v0.12.2


root@frankfurter:~# ./node ./node_modules/browserify/bin/cmd.js -v
9.0.8

root@frankfurter:~# grep "version" ./node_modules/watchify/package.json 
  "version": "3.1.1",

root@frankfurter:~# vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 10 2013 02:28:47)
Included patches: 1-547
Modified by [email protected]
Compiled by [email protected]
Huge version without GUI.  Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
+find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv
+insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
+mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse
+mouse_xterm +mouse_urxvt +multi_byte +multi_lang -mzscheme +netbeans_intg
+path_extra -perl +persistent_undo +postscript +printer +profile -python
-python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
 -xterm_clipboard -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -Wl,-z,relro -Wl,--as-needed -o vim       -lm -ltinfo -lnsl  -lselinux -lacl -lattr -lgpm

root@frankfurter:~# cat a.js
require('./b.js')

root@frankfurter:~# cat b.js
console.log("hello")

root@frankfurter:~# cat package.json
{}

root@frankfurter:~# ./node ./node_modules/watchify/bin/cmd.js ./a.js -o foo.js -v &
[1] 8067

root@frankfurter:~# 591 bytes written to foo.js (0.06 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.05 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.01 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.03 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.03 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.03 seconds)

root@frankfurter:~# # Ok, that works, what about VIM?

root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.01 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.01 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# touch a.js

root@frankfurter:~# # Seems to have stopped watching ./a.js

root@frankfurter:~# kill %1
root@frankfurter:~#
[1]+  Terminated              ./node ./node_modules/watchify/bin/cmd.js ./a.js -o foo.js -v

root@frankfurter:~# # Let's try again, but without package.json

root@frankfurter:~# rm package.json

root@frankfurter:~# ./node ./node_modules/watchify/bin/cmd.js ./a.js -o foo.js -v &
[1] 8095
root@frankfurter:~# 591 bytes written to foo.js (0.16 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.04 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)

root@frankfurter:~# # Now with VIM
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.03 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.01 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.03 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.01 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.01 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)

root@frankfurter:~# kill %1
[1]+  Terminated              ./node ./node_modules/watchify/bin/cmd.js ./a.js -o foo.js -v

root@frankfurter:~# # Let's bring package.json back

root@frankfurter:~# echo "{}" > package.json
root@frankfurter:~# cat package.json
{}

root@frankfurter:~# ./node ./node_modules/watchify/bin/cmd.js ./a.js -o foo.js -v &
[1] 8122
root@frankfurter:~# 591 bytes written to foo.js (0.06 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.04 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.01 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.04 seconds)
root@frankfurter:~# touch a.js
root@frankfurter:~# 591 bytes written to foo.js (0.03 seconds)

root@frankfurter:~# # Now with VIM
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.03 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# 591 bytes written to foo.js (0.02 seconds)
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# vim +:wq ./a.js
root@frankfurter:~# touch ./a.js
root@frankfurter:~# touch ./a.js
root@frankfurter:~#
@zertosh
Copy link
Member

zertosh commented Apr 17, 2015

@rashkov What happens if the output file is written to a directory that is not a descendent of where your js files / package.json are?

@rashkov
Copy link
Author

rashkov commented Apr 17, 2015

That does not seem to fix it:

Linux frankfurter 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u1 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Apr 17 19:18:03 2015 from 38.100.174.226
root@frankfurter:~# ./node -v
v0.12.2
root@frankfurter:~# grep "version" ./node_modules/watchify/package.json 
  "version": "3.1.1",
root@frankfurter:~# grep "version" ./node_modules/browserify/package.json 
  "version": "9.0.8",
(reverse-i-search)`nod': grep "version" ./^Cde_modules/browserify/package.json  
root@frankfurter:~# ./node ./node_modules/watchify/bin/cmd.js ./a.js -o ../foo.js -v &
[1] 3312
root@frankfurter:~# 592 bytes written to ../foo.js (0.07 seconds)

root@frankfurter:~# vim +:wq ./a.js 
root@frankfurter:~# 592 bytes written to ../foo.js (0.03 seconds)

root@frankfurter:~# vim +:wq ./a.js 
root@frankfurter:~# 592 bytes written to ../foo.js (0.04 seconds)

root@frankfurter:~# vim +:wq ./a.js 
root@frankfurter:~# 592 bytes written to ../foo.js (0.02 seconds)

root@frankfurter:~# vim +:wq ./a.js 
root@frankfurter:~# vim +:wq ./a.js 
root@frankfurter:~# vim +:wq ./a.js 
root@frankfurter:~# # Stopped watching a.js
root@frankfurter:~# vim +:wq ./b.js 
root@frankfurter:~# 592 bytes written to ../foo.js (0.03 seconds)

root@frankfurter:~# vim +:wq ./b.js 
root@frankfurter:~# vim +:wq ./b.js 
root@frankfurter:~# vim +:wq ./b.js 
root@frankfurter:~# touch ./b.js 
root@frankfurter:~# # Stopped watching b.js
root@frankfurter:~# 

@rashkov
Copy link
Author

rashkov commented Apr 17, 2015

Happy to add your public key to that debian instance if you'd like to SSH in and do any testing.

@zertosh
Copy link
Member

zertosh commented Apr 24, 2015

@rashkov I'm going to close this in favor of #205 - since that's got a bit more discussion.

@zertosh zertosh closed this as completed Apr 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants