{"record":{"id":"590671b7aabb8015","repo":"Hmbown/CodeWhale","slug":"runtime-api-server-error-e","errorCode":null,"errorMessage":"Runtime API server error: {e}","messagePattern":"Runtime API server error: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_api.rs","lineNumber":1092,"sourceCode":"        );\n        if !auth_enabled {\n            println!(\n                \"  WARNING: auth is disabled. Anyone on the network can call /v1/* without authentication.\"\n            );\n        }\n        println!(\n            \"  /v1/runtime/info reports bind_host={host:?}, port={port}, auth_required={auth}.\",\n            host = options.host,\n            port = options.port,\n            auth = auth_enabled,\n        );\n    }\n    let serve_result = axum::serve(\n        listener,\n        app.into_make_service_with_connect_info::<SocketAddr>(),\n    )\n    .await\n    .map_err(|e| anyhow!(\"Runtime API server error: {e}\"));\n    scheduler_cancel.cancel();\n    scheduler_handle.abort();\n    task_manager.shutdown_and_wait().await?;\n    serve_result\n}\n\n/// Mobile control uses plain HTTP only on loopback. It has no TLS or verified\n/// overlay transport, so a non-loopback listener would expose the Runtime API\n/// to peers that can observe or replay browser traffic.\nfn validate_runtime_listener_security(options: &RuntimeApiOptions) -> Result<()> {\n    if options.port == 0 {\n        bail!(\"Port must be > 0\");\n    }\n    if options.web && options.host != \"127.0.0.1\" {\n        bail!(\"Codewhale web is loopback-only and must bind to 127.0.0.1\");\n    }\n    if options.web && options.insecure_no_auth {\n        bail!(\"Codewhale web requires Runtime authentication; remove --insecure\");","sourceCodeStart":1074,"sourceCodeEnd":1110,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_api.rs#L1074-L1110","documentation":"The Runtime API's axum::serve future, awaited after the listener is bound, failed while serving HTTP requests. The underlying hyper/io error is interpolated into this anyhow error and returned after the scheduler is cancelled and the task manager is shut down, so the whole runtime API server is stopping with this error.","triggerScenarios":"axum::serve returning Err during accept/serve of HTTP connections on the bound listener — typically when the listener socket becomes unusable (fd exhaustion, EPERM, IO error) or the serve loop encounters an unrecoverable IO error while handling connections.","commonSituations":"Running out of file descriptors under many concurrent Runtime API clients, the OS killing the socket, port security software interfering after bind, or disk/IO failures during request handling.","solutions":["Read the interpolated hyper/IO error for the root cause; it names the failing syscall or condition.","Check the process file-descriptor limit (ulimit -n) and raise it if 'Too many open files' appears.","Ensure nothing else disrupts the bound port (firewall, sandbox, container port mapping) and restart the Runtime API.","Confirm the app is current; transient accept failures on old axum/hyper versions may need a dependency update."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight: confirm the port is bindable and fd headroom exists\nlet probe = std::net::TcpListener::bind((\"127.0.0.1\", port));\nlet fd_ok = std::fs::read_dir(\"/proc/self/fd\").map(|d| d.count() < 8000).unwrap_or(true);","typeGuard":null,"tryCatchPattern":"match serve_result {\n    Ok(()) => {},\n    Err(e) => { scheduler_cancel.cancel(); log::error!(\"runtime API stopped: {e:#}\"); }\n}","preventionTips":["Raise the process fd limit before starting long-lived servers","Monitor the Runtime API port health and restart on repeated serve failures","Keep axum/hyper updated for accepted-error robustness fixes"],"tags":["axum","http","server","network"],"backgroundTag":"http-server-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}