fix(api): disable reqwest connection pool

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.
This commit is contained in:
syoul
2026-04-26 00:18:59 +02:00
parent 9fe24c72cb
commit 7981fc571c

View File

@@ -22,8 +22,15 @@ pub struct MyceliumClient {
impl MyceliumClient {
pub fn new(base: impl Into<String>) -> 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 {