Hmbown/CodeWhale · error

Runtime API server error

Error message

Runtime API server error: {e}

What it means

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.

Solutions

  1. Read the interpolated hyper/IO error for the root cause; it names the failing syscall or condition.
  2. Check the process file-descriptor limit (ulimit -n) and raise it if 'Too many open files' appears.
  3. Ensure nothing else disrupts the bound port (firewall, sandbox, container port mapping) and restart the Runtime API.
  4. Confirm the app is current; transient accept failures on old axum/hyper versions may need a dependency update.
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight: confirm the port is bindable and fd headroom exists
let probe = std::net::TcpListener::bind(("127.0.0.1", port));
let fd_ok = std::fs::read_dir("/proc/self/fd").map(|d| d.count() < 8000).unwrap_or(true);

Try / catch

match serve_result {
    Ok(()) => {},
    Err(e) => { scheduler_cancel.cancel(); log::error!("runtime API stopped: {e:#}"); }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/590671b7aabb8015. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/runtime_api.rs:1092

        );
        if !auth_enabled {
            println!(
                "  WARNING: auth is disabled. Anyone on the network can call /v1/* without authentication."
            );
        }
        println!(
            "  /v1/runtime/info reports bind_host={host:?}, port={port}, auth_required={auth}.",
            host = options.host,
            port = options.port,
            auth = auth_enabled,
        );
    }
    let serve_result = axum::serve(
        listener,
        app.into_make_service_with_connect_info::<SocketAddr>(),
    )
    .await
    .map_err(|e| anyhow!("Runtime API server error: {e}"));
    scheduler_cancel.cancel();
    scheduler_handle.abort();
    task_manager.shutdown_and_wait().await?;
    serve_result
}

/// Mobile control uses plain HTTP only on loopback. It has no TLS or verified
/// overlay transport, so a non-loopback listener would expose the Runtime API
/// to peers that can observe or replay browser traffic.
fn validate_runtime_listener_security(options: &RuntimeApiOptions) -> Result<()> {
    if options.port == 0 {
        bail!("Port must be > 0");
    }
    if options.web && options.host != "127.0.0.1" {
        bail!("Codewhale web is loopback-only and must bind to 127.0.0.1");
    }
    if options.web && options.insecure_no_auth {
        bail!("Codewhale web requires Runtime authentication; remove --insecure");

View on GitHub (pinned to 73e0f67d83)