block/buzz · error · anyhow::Error

failed to build Tokio runtime: {error}

Error message

failed to build Tokio runtime: {error}

What it means

Raised in main when tokio::runtime::Builder::new_multi_thread().enable_all().build() fails, meaning the multi-threaded Tokio runtime could not be created before any relay startup work begins. This is a fatal, pre-boot failure — typically caused by OS resource limits (thread creation failure, insufficient memory) — and the error is wrapped via BootTracker so startup telemetry records the failure before the process exits with the anyhow error.

Source

Thrown at crates/buzz-relay/src/main.rs:114

                EmissionScope::All
            }
        }
    }

    fn allows(&self, _community_id: &Uuid) -> bool {
        matches!(self, Self::All)
    }
}

const USAGE_METRICS_LOCK_KEY: i64 = 0x4255_5A5A_4D45_5452;

fn main() -> anyhow::Result<()> {
    let (runtime, boot) = BootTracker::start_before_runtime(|| {
        tokio::runtime::Builder::new_multi_thread()
            .enable_all()
            .build()
    })
    .map_err(|error| anyhow::anyhow!("failed to build Tokio runtime: {error}"))?;
    runtime.block_on(run_relay_main(boot))
}

async fn run_relay_main(boot: BootTracker) -> anyhow::Result<()> {
    // Install the ring CryptoProvider for rustls. Required before any rustls
    // TLS connection (rediss:// to ElastiCache, wss://, S3 over TLS): both
    // aws-lc-rs and ring are compiled in transitively, so rustls can't
    // auto-select a provider and would panic at first use without this.
    let (mut boot, ()) = boot
        .run_required(
            StartupPhase::CryptoInit,
            || {
                rustls::crypto::ring::default_provider()
                    .install_default()
                    .map_err(|_provider| ())
            },
            |_error| LifecycleReason::ProviderConflict,
        )

View on GitHub (pinned to dad5a33865)

Solutions

  1. Free system memory or raise the thread/process resource limits (ulimit) that prevented Tokio from spawning worker threads
  2. Retry on a machine with adequate resources; the failure is environmental, not a configuration bug
  3. Check kernel logs for thread-allocation failures if the error persists
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/buzz-relay/src/main.rs:114 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of block/buzz@dad5a33865 (2026-09-05). Data as JSON: /api/errors/f29986f6b738c806. Report an issue: GitHub.