Skip to content

Commit 6d19765

Browse files
panagosg7meta-codesync[bot]
authored andcommitted
[flow] Suppress spurious EdenFS watcher error on clean shutdown
Summary: Changelog: [internal] During `flow stop`, the exit hook destroys the EdenFS watcher instance before the listen loop is canceled. When Lwt yields during the 1-second shutdown window, the listen loop wakes up and tries to call get_changes_async on the destroyed instance, producing a spurious "EdenfsWatcherInstance was previously destroyed" error that gets logged to Scuba as EDENFS_WATCHER_ERROR. Detect this specific error in the listen loop and treat it as a clean shutdown (Lwt.Canceled) instead of an error. This prevents false error events from polluting Scuba on every normal `flow stop`. Reviewed By: SamChou19815 Differential Revision: D94991663 fbshipit-source-id: bbe0eef3165bea16de8a0eb2f59c1062062333b1
1 parent 69daa70 commit 6d19765

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/hack_forked/stubs/edenfs_watcher/edenfs_watcher.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ let is_available () = false
2929
let watch_spec _options = failwith "not implemented"
3030

3131
let hooks_upon_clean_exit : (unit -> unit) list ref = ref []
32+
33+
let is_instance_destroyed () = false

src/monitor/fileWatcher.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,11 @@ end = struct
686686
{ MonitorProt.changed_mergebase = None; missed_changes = true };
687687
broadcast env;
688688
Lwt.return env
689+
| Error _ when Edenfs_watcher.is_instance_destroyed () ->
690+
(* The instance was destroyed by the exit hook during shutdown.
691+
This is expected and not an error — treat it as a clean stop. *)
692+
Logger.info "EdenFS watcher instance was destroyed (shutdown in progress)";
693+
raise Lwt.Canceled
689694
| Error err ->
690695
let msg = Edenfs_watcher.show_edenfs_watcher_error err in
691696
let backtrace = Printexc.get_backtrace () in

0 commit comments

Comments
 (0)