joyent/node — Issue #2837: watcher.close() throws exception if no "error" handler registered
Author: cowboy
Created: 2012-02-27 19:47:13+00:00
State: open

In Windows XP using Node.js v0.6.11, this code explodes:

```javascript
var fs = require('fs');
var w = fs.watch('README.md', function() {});
w.close();
```

Throwing this exception:

```
events.js:48
throw arguments[1]; // Unhandled 'error' event
^
Error: watch Unknown system errno 995
at errnoException (fs.js:636:11)
at FSEvent.onchange (fs.js:650:26)
```

While this code does not:

```javascript
var fs = require('fs');
var w = fs.watch('README.md', function() {});
w.on('error', function() {}); // I probably shouldn't have to do this
w.close();
```

Both work just fine in OS X 10.7, I haven't tested in Windows 7.