-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Mac: fs.watch triggered twice on fs.writeFile #2054
Comments
Same on Ubuntu (running 11.04) |
BTW, when I run the above code by Trevor, it outputs: node: src/unix/core.c:149: uv_close: Assertion `0' failed. |
@khoomeister That's what happens when you try to watch a file that doesn't already exist. And yes, it would be nice if Node provided an error to that effect. On Nov 9, 2011, at 3:21 AM, khoomeisterreply@reply.github.com wrote:
|
Oh - thanks for that. |
The double notification is because a write to a file triggers two kqueue events NOTE_EXTEND and NOTE_WRITE. These can either be bundled in the same event if the check interval is fast enough, or be sent as separate events. In which case, should this be considered a libuv bug? Because a pure kqueue program behaves in the same way. The second part about throwing an error on non-existent file has been fixed, you now get an ENOENT on release builds |
How long to wait for correction? var blocked = {};
// decorator
function wch(fn) {
return function(event, path) {
if(path in blocked) return;
blocked[path] = true;
setTimeout(function() { delete blocked[path] }, 25);
fn(event, path);
}
}
fs.watch(pathdir, wch(function(event, filename) { ... })); There are more reliable solutions? |
Related: #1970. Tested under Mac OS 10.7.2. Here's the code:
The output I get is usually
though sometimes it's just the expected
The text was updated successfully, but these errors were encountered: