shama/gaze — pull request #42 by chrisirhc (2013-07-04 01:47:09+00:00)
Title: watchDir does not respect `close` during race condition

When a change is made right during the close method, before the timeout
of the watchDir is executed, the watcher gets revived into a state where
it prevents new watchers from watching the same directory and triggering
the event.

This is difficult to reproduce as it requires another process to keep hitting the files during the close of a Gaze object.

Sequence of events that to reproduce:

1. File change occurs
2. `_watchDir` fires
3. timeout set from `watchDir` for 110ms
4. Call to `close` on watcher
5. timeout fires from `watchDir`
6. `done` method gets called and watchers get re-added to `this._watchers` of the already closed watcher.