Skip to content

Instantly share code, notes, and snippets.

@dlmanning
Last active December 23, 2015 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlmanning/6618028 to your computer and use it in GitHub Desktop.
Save dlmanning/6618028 to your computer and use it in GitHub Desktop.
Possible regression between 0.10.16 and 0.10.17 related to libuv patch
Running watch.js on node 0.10.17 and OS X 10.8.5 gives the following when editing (in Sublime Text) and saving file in the same directory:
change : a.txt
rename : .subl319.tmp
change : a.txt
rename : .subl69d.tmp
etc...
Doing the same on 0.10.18 gives:
rename : .subl738.tmp
rename : .sublade.tmp
The same issue occurs between 0.11.6 and 0.11.7. Based on the commit log I think it's related to the following change in libuv:
https://github.com/joyent/libuv/commit/9bae606d413327187828155b61babcd52b2d2517
var fs = require('fs');
fs.watch(__dirname, function (evt, filename) {
console.log(evt + ' : ' + filename);
})
@airportyh
Copy link

Thanks! I just tested on my Mac 10.7.5 and got a slightly different result

$ node -v
v0.10.18

$ node watch.js
rename : a.txt
rename : a.txt
rename : a.txt

$ node -v
v0.10.17

$ node watch.js
rename : a.txt
rename : a.txt
change : a.txt
change : a.txt

What version of Sublime Text do you have? Because I am not getting the strangly named tmp files.

@dlmanning
Copy link
Author

Toby,

Sorry I didn't see your response before. I'm using Sublime Text 3. It looks like ST2 writes the files to the same location rather than saving to a temp and moving. vim does the same thing as ST3, though, so I don't understand how no one's noticed this.

Anyway, fireworm is continuing to work with ST2 because you're checking the filename associated with the event.

I'm pretty sure FSWatcher should be emitting a change event for the original filename along with the rename event in any case.

@jarofghosts
Copy link

For posterity, it seems to me that any change that occurs within ~200ms of another does not get emitted.. writing a test.

@dlmanning
Copy link
Author

@dlmanning
Copy link
Author

Turns out this was "fixed" when libuv 0.10.18 was rolled into node 0.10.21

joyent/libuv@38df93c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment