Kuberwastaken/claurst · error
No screenshot data in response
Error message
No screenshot data in response
What it means
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).
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.
Example fix
// defensive caller
match chrome_screenshot() {
Ok(path) => println!("saved {}", path),
Err(e) if e.to_string().contains("No screenshot data") => {
chrome_reconnect()?; // stale/failed target
chrome_screenshot()?;
}
Err(e) => return Err(e),
} Defensive patterns
Strategy: try-catch
Validate before calling
// verify the session's tab is still open before capture
let alive: bool = cdp_call(ws, "Runtime.evaluate", json!({"expression": "!document.closed"})).await?.get("result").is_some();
if !alive { reconnect()?; } Type guard
fn extract_b64(resp: &Value) -> Option<&str> {
resp["result"]["data"].as_str().filter(|s| !s.is_empty())
} Try / catch
match screenshot().await {
Ok(p) => Ok(p),
Err(e) if e.to_string().contains("No screenshot data") => {
reconnect()?;
screenshot().await
}
Err(e) => Err(e),
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- WebSocket closed unexpectedly
- WebSocket closed by Chrome
- CDP error
- No debuggable page found on port
- WebSocket connect to
AI-assisted analysis of Kuberwastaken/claurst@b0637c97ec (2026-09-10).
Data as JSON: /api/errors/60321e78f03734cd.
Report an issue: GitHub.
Appendix: source
Thrown at src-rust/crates/commands/src/chrome.rs:200
}
.await;
store_session(s);
result
}
/// Take a screenshot, write PNG to a temp file, return the path.
pub async fn screenshot() -> anyhow::Result<String> {
let mut s = take_session()?;
let result = async {
let resp = cdp_call(
&mut s.ws,
"Page.captureScreenshot",
json!({ "format": "png", "captureBeyondViewport": false }),
)
.await?;
let b64 = resp["result"]["data"]
.as_str()
.ok_or_else(|| anyhow::anyhow!("No screenshot data in response"))?;
let bytes = base64::engine::general_purpose::STANDARD.decode(b64)?;
let tmp = tempfile::Builder::new()
.prefix("cc-chrome-")
.suffix(".png")
.tempfile()?;
let path = tmp.path().to_path_buf();
std::fs::write(&path, &bytes)?;
// Persist file past the NamedTempFile drop.
let _ = tmp.keep()?;
Ok(format!("Screenshot saved to {}", path.display()))
}
.await;
store_session(s);
result
}
/// Click the first element matching a CSS selector.
View on GitHub (pinned to b0637c97ec)