{"record":{"id":"ed35a19a4c5b7ec8","repo":"astrid-runtime/astrid","slug":"shutdown-stage-gateway-startup-stop-a-starting-ga","errorCode":null,"errorMessage":"shutdown stage gateway.startup_stop: a starting gateway did not become stoppable within {} seconds","messagePattern":"shutdown stage gateway\\.startup_stop: a starting gateway did not become stoppable within (.+?) seconds","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/mcp/lifecycle.rs","lineNumber":539,"sourceCode":"    }\n    let Some(record) = read_gateway_ready()? else {\n        let deadline = Instant::now()\n            .checked_add(READY_TIMEOUT)\n            .unwrap_or_else(Instant::now);\n        while try_acquire_gateway_lifecycle()?.is_none() {\n            if let Some(record) = read_gateway_ready()? {\n                return stop_ready_gateway(record, socket).await;\n            }\n            if let Some(lease) = read_gateway_startup_lease()?\n                && lease\n                    .gateway_pid\n                    .is_some_and(crate::commands::daemon_control::is_process_alive)\n            {\n                stop_startup_gateway(&lease).await?;\n                continue;\n            }\n            if Instant::now() >= deadline {\n                anyhow::bail!(\n                    \"shutdown stage gateway.startup_stop: a starting gateway did not become stoppable within {} seconds\",\n                    READY_TIMEOUT.as_secs()\n                );\n            }\n            tokio::time::sleep(READY_POLL).await;\n        }\n        let lifecycle = try_acquire_gateway_lifecycle()?.ok_or_else(|| {\n            anyhow::anyhow!(\"shutdown stage gateway.startup_stop: lifecycle changed\")\n        })?;\n        clean_unowned_gateway_startup(&lifecycle)\n            .await\n            .context(\"shutdown stage gateway.stale_listener_cleanup\")?;\n        drop(lifecycle);\n        return Ok(());\n    };\n    stop_ready_gateway(record, socket).await\n}\n","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/mcp/lifecycle.rs#L521-L557","documentation":"Fired by stop_gateway's shutdown stage gateway.startup_stop when a gateway that is still starting does not reach a stoppable state within READY_TIMEOUT. The shutdown path gives the starting gateway a grace window, then gives up rather than waiting forever.","triggerScenarios":"Thrown at crates/astrid-cli/src/commands/mcp/lifecycle.rs:539 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Force-kill the starting gateway/supervisor process","Clean leftover startup lease and ready-record files, then restart","Investigate why the gateway never became stoppable (logs, resource starvation)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}