{"record":{"id":"221e15bb8a965c8a","repo":"gleam-lang/gleam","slug":"unable-to-start-tokio-async-runtime-221e15","errorCode":null,"errorMessage":"Unable to start Tokio async runtime","messagePattern":"Unable to start Tokio async runtime","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler-cli/src/hex.rs","lineNumber":39,"sourceCode":"    match credentials {\n        hexpm::Credentials::ApiKey(key) => Ok(hexpm::WriteActionCredentials::ApiKey(key.clone())),\n        hexpm::Credentials::OAuthAccessToken(token) => {\n            let one_time_password = cli::ask(\"Enter your two-factor authentication code\")?.into();\n            Ok(hexpm::WriteActionCredentials::OAuthAccessToken {\n                access_token: token.clone(),\n                one_time_password,\n            })\n        }\n    }\n}\n\npub fn retire(\n    package: String,\n    version: String,\n    reason: RetirementReason,\n    message: Option<String>,\n) -> Result<()> {\n    let runtime = tokio::runtime::Runtime::new().expect(\"Unable to start Tokio async runtime\");\n    let config = hexpm::Config::new();\n    let http = HttpClient::new();\n    let credentials =\n        HexAuthentication::new(&runtime, &http, config.clone()).get_or_create_api_credentials()?;\n\n    runtime.block_on(hex::retire_release(\n        &package,\n        &version,\n        reason,\n        message.as_deref(),\n        &write_credentials(&credentials)?,\n        &config,\n        &http,\n    ))?;\n    cli::print_retired(&package, &version);\n    Ok(())\n}\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/gleam-lang/gleam/blob/7e623aa83da3776faee50ca4ab9a6c40124acd95/compiler-cli/src/hex.rs#L21-L57","documentation":"`gleam hex retire` (compiler-cli/src/hex.rs:39) starts a Tokio runtime to authenticate and call `hex::retire_release`. If `tokio::runtime::Runtime::new()` cannot create its worker threads or IO/time driver descriptors, the `.expect(\"Unable to start Tokio async runtime\")` panics and the command exits before any Hex API call is made.","triggerScenarios":"Running `gleam hex retire <pkg> <ver> --reason ...` where thread creation or epoll/timerfd creation fails: `ulimit -u`/cgroup pids limits, `ulimit -n` exhaustion, no memory for thread stacks, or sandboxed syscalls blocked.","commonSituations":"Release-maintenance automation in capped containers; CI agents whose fd table is full from earlier steps; minimal scratch/distroless images with restrictive defaults.","solutions":["Raise thread/process limits (`ulimit -u`, container pids limit)","Raise fd limits (`ulimit -n 4096`) and fix fd leaks","Ensure memory headroom for runtime threads","Allow Tokio's syscalls (`clone`, `epoll_create1`, `eventfd`, `timerfd_*`) in seccomp/AppArmor","Retry `gleam hex retire` after the environment is fixed"],"exampleFix":"# before: panics 'Unable to start Tokio async runtime'\n\n# after: run with sane limits in the release job\nbash -c 'ulimit -n 4096; gleam hex retire mypkg 1.0.0 --reason invalid'","handlingStrategy":"validation","validationCode":"# retire with limits fixed inline\nbash -c 'ulimit -n 4096; gleam hex retire \"$0\" \"$1\" --reason other' \"$PKG\" \"$VER\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run hex maintenance commands from the same CI environment used for publishing","Pre-authenticate and store credentials so maintenance runs need fewer moving parts"],"tags":["gleam","tokio","async-runtime","hex","retire","resource-limits"],"backgroundTag":"tokio-runtime-start-failed","analyzedSha":"7e623aa83da3776faee50ca4ab9a6c40124acd95","analyzedAt":"2026-08-17T00:07:02.091Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}