I observed two bugs in the DirectoryWatcher on macOS
- We were calling FSEventStreamStop and FSEventStreamInvalidate before we called FSEventStreamStart and FSEventStreamSetDispatchQueue, if the DirectoryWatcher was destroyed before the initial async work was done. This violates the requirements of the FSEvents API.
- Calls to Receiver could race between the initial work and the invalidation during destruction.
The second issue is easier to see when using TSan.