{"record":{"id":"c953237e103b07b5","repo":"Kuberwastaken/claurst","slug":"no-active-chrome-session-run-chrome-connect-fi","errorCode":null,"errorMessage":"No active Chrome session. Run `/chrome connect` first.","messagePattern":"No active Chrome session\\. Run `/chrome connect` first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-rust/crates/commands/src/chrome.rs","lineNumber":100,"sourceCode":"                    return Err(anyhow::anyhow!(\"CDP error: {}\", err));\r\n                }\r\n                return Ok(val);\r\n            }\r\n            // It's an event or different response — keep waiting.\r\n        }\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r\n    // Session take/restore helpers\r\n    //\r\n    // We avoid holding a MutexGuard across await points by taking ownership\r\n    // of the session, performing all async operations with it, then putting\r\n    // it back into the global.\r\n    // -----------------------------------------------------------------------\r\n\r\n    fn take_session() -> anyhow::Result<ChromeSession> {\r\n        SESSION.lock().take().ok_or_else(|| {\r\n            anyhow::anyhow!(\"No active Chrome session. Run `/chrome connect` first.\")\r\n        })\r\n    }\r\n\r\n    fn store_session(s: ChromeSession) {\r\n        *SESSION.lock() = Some(s);\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r\n    // Public helpers called from the SlashCommand impl\r\n    // -----------------------------------------------------------------------\r\n\r\n    /// Connect to Chrome at the given port.\r\n    /// Picks the first available target (tab/page).\r\n    pub async fn connect(port: u16) -> anyhow::Result<String> {\r\n        let http_url = format!(\"http://localhost:{}/json/list\", port);\r\n        let client = reqwest::Client::builder()\r\n            .timeout(std::time::Duration::from_secs(3))\r\n            .build()?;\r","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/commands/src/chrome.rs#L82-L118","documentation":"Thrown by `take_session` in src-rust/crates/commands/src/chrome.rs when no Chrome session is stored in the global SESSION mutex. Commands like navigate, screenshot, click, fill, and eval call take_session to pop the session from the global slot; `.take()` returns None when `connect` was never run or the session was not put back. The library requires an explicit `/chrome connect` step before any CDP operation.","triggerScenarios":"Calling any Chrome command (navigate, screenshot, click, fill, eval) before `/chrome connect` has stored a ChromeSession in the global SESSION slot.","commonSituations":"Fresh app start where the user issues `/chrome navigate` first; a previous session was consumed/failed and never restored; Chrome was closed between commands and session teardown removed it; a script calls subcommands out of order.","solutions":["Run `/chrome connect` first so a session is stored in the global slot.","Ensure the Chrome binary is running with the remote debugging port before connecting.","In code, check for an active session (or call connect) before invoking navigate/screenshot/click/fill/eval."],"exampleFix":"// before\n/chrome navigate https://example.com\n// error: No active Chrome session\n\n// after\n/chrome connect\n/chrome navigate https://example.com","handlingStrategy":"validation","validationCode":"// check the global session slot before running a command\nif !chrome::has_active_session() {\n    chrome::connect(port)?;\n}","typeGuard":"fn has_session(s: &Option<ChromeSession>) -> bool { s.is_some() }","tryCatchPattern":"match take_session() {\n    Ok(s) => operate(s),\n    Err(_) => connect_and_retry(),\n}","preventionTips":["Always run connect before any chrome subcommand.","Wrap multi-step chrome automation behind a helper that ensures connection first.","Reconnect after Chrome restarts or long idle periods."],"tags":["chrome","session","state-machine","cli"],"backgroundTag":"invalid-state-transition","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}