From e83be207989be2d99979adbd99181bd5392a8de9 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Wed, 11 Mar 2026 11:36:47 +0100 Subject: [PATCH] fix(appd): make appd.wsport write non-fatal when XDG_RUNTIME_DIR is unset write_ws_port failure is now logged as a warning rather than propagating an error that would crash the service. Error context strings are added to create_dir_all and write failures so the warning is actionable. --- crates/weft-appd/src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/weft-appd/src/main.rs b/crates/weft-appd/src/main.rs index fb4b2a7..d50fda0 100644 --- a/crates/weft-appd/src/main.rs +++ b/crates/weft-appd/src/main.rs @@ -132,7 +132,9 @@ async fn run() -> anyhow::Result<()> { .with_context(|| format!("bind WebSocket {ws_addr}"))?; let ws_bound_port = ws_listener.local_addr()?.port(); tracing::info!(port = ws_bound_port, "WebSocket listener ready"); - write_ws_port(ws_bound_port)?; + if let Err(e) = write_ws_port(ws_bound_port) { + tracing::warn!(error = %e, "could not write appd.wsport; servo-shell port discovery will fall back to default"); + } let _ = sd_notify::notify(false, &[sd_notify::NotifyState::Ready]); @@ -196,9 +198,9 @@ fn write_ws_port(port: u16) -> anyhow::Result<()> { let runtime_dir = std::env::var("XDG_RUNTIME_DIR").context("XDG_RUNTIME_DIR not set")?; let path = PathBuf::from(runtime_dir).join("weft/appd.wsport"); if let Some(parent) = path.parent() { - std::fs::create_dir_all(parent)?; + std::fs::create_dir_all(parent).with_context(|| format!("create {}", parent.display()))?; } - std::fs::write(&path, port.to_string())?; + std::fs::write(&path, port.to_string()).with_context(|| format!("write {}", path.display()))?; Ok(()) }