From bbcc8a3d29bca565d2d2f3ab5b56ea849bb81ed3 Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Mon, 23 Aug 2021 10:12:31 +0200 Subject: [PATCH] fix: Wait 50ms before reloading config, to avoid reading an empty file --- crates/eww/src/server.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/eww/src/server.rs b/crates/eww/src/server.rs index b31e5de..49bfbce 100644 --- a/crates/eww/src/server.rs +++ b/crates/eww/src/server.rs @@ -167,6 +167,11 @@ async fn run_filewatch>(config_dir: P, evt_send: UnboundedSender< }); let (daemon_resp_sender, mut daemon_resp_response) = daemon_response::create_pair(); + // without this sleep, reading the config file sometimes gives an empty file. + // This is probably a result of editors not locking the file correctly, + // and eww being too fast, thus reading the file while it's empty. + // There should be some cleaner solution for this, but this will do for now. + tokio::time::sleep(std::time::Duration::from_millis(50)).await; evt_send.send(app::DaemonCommand::ReloadConfigAndCss(daemon_resp_sender))?; tokio::spawn(async move { match daemon_resp_response.recv().await {