From 7981fc571c02a41c936f1ab1ac2812b89bc8e8e1 Mon Sep 17 00:00:00 2001 From: syoul Date: Sun, 26 Apr 2026 00:18:59 +0200 Subject: [PATCH] fix(api): disable reqwest connection pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Direct mycelium runs and our pkexec spawns are both healthy (sidecar logs show acquired routes streaming for 20+s). Yet our reqwest poller can't reach 127.0.0.1:port after the first successful request. Smoking gun: failure happens ~10s after the first reply — exactly when an idle keep-alive connection would have been reaped. Disable pooling (pool_max_idle_per_host(0)) so every call opens a fresh TCP connection. Loopback overhead is negligible (~50us per request) and we're immune to server-side idle closes. Also pin connect_timeout to 3s so a wedged half-open doesn't block for the full 10s request timeout. --- src-tauri/src/api/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src-tauri/src/api/mod.rs b/src-tauri/src/api/mod.rs index fc96336..5ea20f7 100644 --- a/src-tauri/src/api/mod.rs +++ b/src-tauri/src/api/mod.rs @@ -22,8 +22,15 @@ pub struct MyceliumClient { impl MyceliumClient { pub fn new(base: impl Into) -> Self { + // Mycelium's HTTP server seems to drop idle keep-alive connections + // around the 10s mark; reusing a pooled stale connection surfaces + // as a generic "error sending request" once `start_daemon` + // returned. Open a fresh TCP connection per request — overhead is + // negligible on loopback and immune to server-side closes. let http = Client::builder() + .pool_max_idle_per_host(0) .timeout(Duration::from_secs(10)) + .connect_timeout(Duration::from_secs(3)) .build() .expect("reqwest client build"); Self {