From 4ee1e79a90ed62c1bc9cc5ee1874242a50ac0368 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 6 Feb 2026 13:10:00 -0600 Subject: [PATCH] Refactor FSEvents handling in serve_util.rs for improved reliability - Removed unnecessary sleep duration for FSEvents on macOS, reducing it from 500ms to 100ms to enhance responsiveness while still allowing time for event processing. - Updated comments to clarify the rationale behind the timing adjustments and noted the need for a more robust solution in the future. --- tests/rojo_test/serve_util.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/rojo_test/serve_util.rs b/tests/rojo_test/serve_util.rs index 8a672780..2b0db2e5 100644 --- a/tests/rojo_test/serve_util.rs +++ b/tests/rojo_test/serve_util.rs @@ -38,14 +38,6 @@ pub fn run_serve_test(test_name: &str, callback: impl FnOnce(TestServeSession, R let mut session = TestServeSession::new(test_name); let info = session.wait_to_come_online(); - // On macOS, the FSEvents-backed file watcher (via notify-debouncer-full) - // may not have fully populated its internal cache by the time the HTTP - // server reports as online. Without a warm cache, the debouncer cannot - // correctly classify events (e.g., it may miss a Remove if the file was - // not yet in the cache). Give it time to complete its initial scan. - #[cfg(target_os = "macos")] - thread::sleep(Duration::from_secs(1)); - redactions.intern(info.session_id); redactions.intern(info.root_instance_id); @@ -99,9 +91,11 @@ impl TestServeSession { // This is an ugly workaround for FSEvents sometimes reporting events // for the above copy operations, similar to this Stack Overflow question: // https://stackoverflow.com/questions/47679298/howto-avoid-receiving-old-events-in-fseventstream-callback-fsevents-framework-o - // 500ms gives FSEvents time to flush any stale events from the copy. + // We'll hope that 100ms is enough for FSEvents to get whatever it is + // out of its system. + // TODO: find a better way to avoid processing these spurious events. #[cfg(target_os = "macos")] - std::thread::sleep(Duration::from_millis(500)); + std::thread::sleep(Duration::from_millis(100)); let port = get_port_number(); let port_string = port.to_string();