{"record":{"id":"60321e78f03734cd","repo":"Kuberwastaken/claurst","slug":"no-screenshot-data-in-response","errorCode":null,"errorMessage":"No screenshot data in response","messagePattern":"No screenshot data in response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-rust/crates/commands/src/chrome.rs","lineNumber":200,"sourceCode":"        }\r\n        .await;\r\n        store_session(s);\r\n        result\r\n    }\r\n\r\n    /// Take a screenshot, write PNG to a temp file, return the path.\r\n    pub async fn screenshot() -> anyhow::Result<String> {\r\n        let mut s = take_session()?;\r\n        let result = async {\r\n            let resp = cdp_call(\r\n                &mut s.ws,\r\n                \"Page.captureScreenshot\",\r\n                json!({ \"format\": \"png\", \"captureBeyondViewport\": false }),\r\n            )\r\n            .await?;\r\n            let b64 = resp[\"result\"][\"data\"]\r\n                .as_str()\r\n                .ok_or_else(|| anyhow::anyhow!(\"No screenshot data in response\"))?;\r\n            let bytes = base64::engine::general_purpose::STANDARD.decode(b64)?;\r\n\r\n            let tmp = tempfile::Builder::new()\r\n                .prefix(\"cc-chrome-\")\r\n                .suffix(\".png\")\r\n                .tempfile()?;\r\n            let path = tmp.path().to_path_buf();\r\n            std::fs::write(&path, &bytes)?;\r\n            // Persist file past the NamedTempFile drop.\r\n            let _ = tmp.keep()?;\r\n            Ok(format!(\"Screenshot saved to {}\", path.display()))\r\n        }\r\n        .await;\r\n        store_session(s);\r\n        result\r\n    }\r\n\r\n    /// Click the first element matching a CSS selector.\r","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/commands/src/chrome.rs#L182-L218","documentation":"Thrown by the `screenshot` command when the CDP `Page.captureScreenshot` response has no string at `result.data`. CDP normally returns base64 PNG data there; a missing field means Chrome did not produce a screenshot payload (e.g. the target closed, page crashed, or an error result was returned instead).","triggerScenarios":"Page.captureScreenshot returns a response lacking result.data — target tab closed mid-call, renderer crashed, or CDP returned an error object instead of a data payload.","commonSituations":"Screenshotting a tab the user just closed; capturing on a crashed/OOM page; Chrome under heavy load returning an error response; navigating during the capture so the target changed.","solutions":["Re-run `/chrome screenshot` — transient races usually succeed on retry.","Reconnect with `/chrome connect` to get a fresh session bound to a live tab.","Ensure the target tab is open and responsive before screenshotting.","Check the CDP error in the response for a root cause (e.g. target crashed) and address it."],"exampleFix":"// defensive caller\nmatch chrome_screenshot() {\n    Ok(path) => println!(\"saved {}\", path),\n    Err(e) if e.to_string().contains(\"No screenshot data\") => {\n        chrome_reconnect()?; // stale/failed target\n        chrome_screenshot()?;\n    }\n    Err(e) => return Err(e),\n}","handlingStrategy":"try-catch","validationCode":"// verify the session's tab is still open before capture\nlet alive: bool = cdp_call(ws, \"Runtime.evaluate\", json!({\"expression\": \"!document.closed\"})).await?.get(\"result\").is_some();\nif !alive { reconnect()?; }","typeGuard":"fn extract_b64(resp: &Value) -> Option<&str> {\n    resp[\"result\"][\"data\"].as_str().filter(|s| !s.is_empty())\n}","tryCatchPattern":"match screenshot().await {\n    Ok(p) => Ok(p),\n    Err(e) if e.to_string().contains(\"No screenshot data\") => {\n        reconnect()?;\n        screenshot().await\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Reconnect before screenshotting if the session is old or the tab may have closed.","Avoid navigating and screenshotting concurrently.","Retry once on this error — many cases are transient races."],"tags":["chrome","cdp","screenshot","unexpected-response"],"backgroundTag":"unexpected-response-shape","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"}