joyent/node — Issue #2094: Closing FSWatcher shortly after kqueue event causes "assertion failed"
Author: TrevorBurnham
Created: 2011-11-14 01:18:53+00:00
State: open

Running Node 0.6.1 under OS X, the code

var fs = require('fs');
var fswatcher = fs.watch('test', function() {});
fswatcher.close();

(where `'test'` is an existing file or directory) crashes the process with the error

Assertion failed: (revents == EV_LIBUV_KQUEUE_HACK), function uv__fs_event, file src/unix/kqueue.c, line 58.
Abort trap: 6

This code also produces the same error (where `'test.txt'` is an existing file):

var fs = require('fs');
var fswatcher = fs.watch('test.txt', function() {
process.nextTick(function(){
fswatcher.close();
});
});
fs.writeFileSync('test.txt', 'Triggering change event');

I tested the above for several variations of `'change'` and `'rename'` events for both files and directories; got the same error every time.

Probably related (though less serious): #2093.