{"record":{"id":"a5c32b58fb8d64b8","repo":"astrid-runtime/astrid","slug":"shutdown-stage-gateway-process-reap-authenticated","errorCode":null,"errorMessage":"shutdown stage gateway.process_reap: authenticated gateway PID {} did not exit","messagePattern":"shutdown stage gateway\\.process_reap: authenticated gateway PID (.+?) did not exit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/mcp/lifecycle.rs","lineNumber":589,"sourceCode":"            );\n        },\n        astrid_core::local_transport::ConnectOutcome::Absent\n        | astrid_core::local_transport::ConnectOutcome::Stale => {\n            remove_dead_gateway_markers(&record).await?;\n            return Ok(());\n        },\n    };\n\n    request_gateway_control(stream, &record, GatewayControlOperation::Stop)\n        .await\n        .context(\"shutdown stage gateway.final_ack\")?;\n    if !crate::commands::daemon_control::wait_for_exit(\n        record.pid,\n        crate::commands::daemon_control::GRACE,\n    )\n    .await\n    {\n        anyhow::bail!(\n            \"shutdown stage gateway.process_reap: authenticated gateway PID {} did not exit\",\n            record.pid\n        );\n    }\n    remove_dead_gateway_markers(&record).await\n}\n\nasync fn stop_startup_gateway(lease: &GatewayStartupLease) -> Result<()> {\n    let Some(gateway_pid) = lease.gateway_pid else {\n        anyhow::bail!(\"shutdown stage gateway.startup_identity: lease has no gateway PID\");\n    };\n    let Some(gateway_exe) = lease.gateway_exe.as_deref() else {\n        anyhow::bail!(\"shutdown stage gateway.startup_identity: lease has no executable\");\n    };\n    let current = read_gateway_startup_lease()?.ok_or_else(|| {\n        anyhow::anyhow!(\"shutdown stage gateway.startup_identity: lease disappeared\")\n    })?;\n    if current != *lease {","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/mcp/lifecycle.rs#L571-L607","documentation":"Graceful-shutdown timeout in stop_ready_gateway: the stop control request was acknowledged, but the authenticated gateway PID did not exit within the GRACE period. The stage label gateway.process_reap marks that reaping failed; the process may be stuck ignoring SIGTERM-style control, and the caller must treat the gateway as still running.","triggerScenarios":"Thrown at crates/astrid-cli/src/commands/mcp/lifecycle.rs:589 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait a few seconds and check whether the PID exits on its own, then retry the stop","Send SIGTERM/SIGKILL to the PID directly and clean up the socket and readiness files","Inspect gateway logs for shutdown hangs (e.g. stuck request handlers) blocking exit"],"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"}