{"record":{"id":"dc9627bf276af257","repo":"block/buzz","slug":"server-error-e","errorCode":null,"errorMessage":"Server error: {e}","messagePattern":"Server error: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/buzz-relay/src/main.rs","lineNumber":1514,"sourceCode":"        return Ok(());\n    }\n\n    #[cfg(not(unix))]\n    if config.uds_path.is_some() {\n        tracing::warn!(\"BUZZ_UDS_PATH set but UDS not supported on this platform\");\n    }\n\n    // TCP-only path.\n    let mut tcp_rx = shutdown_tx.subscribe();\n    axum::serve(\n        tcp_listener,\n        router.into_make_service_with_connect_info::<std::net::SocketAddr>(),\n    )\n    .with_graceful_shutdown(async move {\n        tcp_rx.changed().await.ok();\n    })\n    .await\n    .map_err(|e| anyhow::anyhow!(\"Server error: {e}\"))?;\n\n    let hard_shutdown = shutdown_handle\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Shutdown task failed: {e}\"))?;\n    hard_shutdown.abort();\n    Ok(())\n}\n\n/// Wait for SIGTERM (Unix) or Ctrl+C.\nasync fn shutdown_signal() {\n    #[cfg(unix)]\n    {\n        use tokio::signal::unix::{signal, SignalKind};\n        let mut sigterm = signal(SignalKind::terminate()).expect(\"install SIGTERM handler\");\n        tokio::select! {\n            _ = tokio::signal::ctrl_c() => {},\n            _ = sigterm.recv() => {},\n        }","sourceCodeStart":1496,"sourceCodeEnd":1532,"githubUrl":"https://github.com/block/buzz/blob/ef2aa1ae38fadcc0bc22b8bf6ed96b35933146be/crates/buzz-relay/src/main.rs#L1496-L1532","documentation":"Identical failure point to 'TCP server error' but on the TCP-only code path of serve() (no UDS configured, non-unix or uds_path None): the axum::serve future for the main relay listener returned Err at crates/buzz-relay/src/main.rs:1390-1397. The bind already succeeded, so this is a runtime accept/serve-loop failure, not a startup config problem.","triggerScenarios":"The graceful-shutdown-wrapped axum::serve on the main router errors with: persistent accept() failures (EMFILE/ENFILE when the process fd limit is exhausted by connection churn), ENOMEM, or errors escaping hyper's per-connection handling. It also fires if the tokio runtime is dropped while serve() is still running, making the future fail instead of being polled to completion.","commonSituations":"Default deployment (no BUZZ_UDS_PATH) under connection storms hitting `ulimit -n`; fd leaks from git smart-HTTP or Blossom media uploads starving accept; running the relay inside a harness that drops the runtime at test end and surfaces the cancelled serve as an error.","solutions":["Raise fd limits (LimitNOFILE / ulimit -n) and check for fd growth: `ls /proc/<pid>/fd | wc -l` sampled over load.","Extract the root cause from the anyhow chain — log with RUST_BACKTRACE=1 and RUST_LOG=buzz_relay=debug.","Let the supervisor restart the relay; the graceful-shutdown wiring means a clean SIGTERM exit is normal, only a mid-run Err here is a defect.","If correlated with media/git traffic, audit those handlers for leaked sockets/streams."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# confirm healthy fd headroom before heavy traffic\n[ \"$(ulimit -n)\" -ge 65536 ] || echo \"warning: low fd limit\" >&2","typeGuard":null,"tryCatchPattern":"// map the terminal serve error to a clean exit code for the supervisor\nlet exit = async {\n    if let Err(e) = serve(...).await {\n        eprintln!(\"Server error: {e}\");\n        1\n    } else { 0 }\n};","preventionTips":["Default (no UDS) deployments still need fd headroom — set LimitNOFILE explicitly everywhere.","Watch relay connection counts and idle-socket age to catch leaks before accept fails.","Do not run the relay under a harness that drops the tokio runtime mid-serve; use the SIGTERM path.","Alert on process restarts tagged with this message; a single occurrence is environmental, repeats indicate leakage."],"tags":["rust","network","runtime","accept-loop","axum","websocket"],"backgroundTag":"listener-accept-failure","analyzedSha":"ef2aa1ae38fadcc0bc22b8bf6ed96b35933146be","analyzedAt":"2026-08-20T04:38:24.874Z","contentChangedAt":"2026-08-20T04:38:24.874Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}