From 41f3826b732e1df5b78db0fb91d9eeb8ce43c4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=B3r=C3=A1nt=20Pint=C3=A9r?= Date: Tue, 18 Feb 2020 10:51:10 +0100 Subject: [PATCH] Do not flush FSEventStream Doing so produces this log: 2020-02-17 23:02 java[50430] (FSEvents.framework) FSEventStreamFlushSync(): failed assertion '(SInt64)last_id > 0LL' The recommendation seems to be not to call FSEventStreamFlushSync() at all. --- src/main/cpp/apple_fsnotifier.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/cpp/apple_fsnotifier.cpp b/src/main/cpp/apple_fsnotifier.cpp index 0ab81b5f..6df50ce6 100644 --- a/src/main/cpp/apple_fsnotifier.cpp +++ b/src/main/cpp/apple_fsnotifier.cpp @@ -150,7 +150,16 @@ void Server::run() { CFRunLoopRun(); - FSEventStreamFlushSync(watcherStream); + // Reading the Apple docs it seems we should call FSEventStreamFlushSync() here. + // But doing so produces this log: + // + // 2020-02-17 23:02 java[50430] (FSEvents.framework) FSEventStreamFlushSync(): failed assertion '(SInt64)last_id > 0LL' + // + // According to this comment we should not use flush at all, and it's probably broken: + // https://github.com/nodejs/node/issues/854#issuecomment-294892950 + // As the comment mentions, even Watchman doesn't flush: + // https://github.com/facebook/watchman/blob/b397e00cf566f361282a456122eef4e909f26182/watcher/fsevents.cpp#L276-L285 + // FSEventStreamFlushSync(watcherStream); FSEventStreamStop(watcherStream); FSEventStreamInvalidate(watcherStream);