RightNow-AI/openfang · error · BrowserResponse
Back succeeded but page info failed: {e}
Error message
Back succeeded but page info failed: {e} What it means
cmd_back executes history.back() via CDP; if that succeeds, it sleeps 500ms, waits for load, then calls page_info() to fetch title/URL/content. If history.back() worked but the subsequent page_info() JS evaluation fails, the library reports this error. Navigation happened, but the post-navigation introspection could not complete — the caller knows the back-action ran but gets no page data.
Source
Thrown at crates/openfang-runtime/src/browser.rs:613
))
}
async fn cmd_run_js(&self, expression: &str) -> BrowserResponse {
match self.cdp.run_js(expression).await {
Ok(val) => BrowserResponse::ok(serde_json::json!({"result": val})),
Err(e) => BrowserResponse::err(format!("JS execution failed: {e}")),
}
}
async fn cmd_back(&self) -> BrowserResponse {
match self.cdp.run_js("history.back(); 'ok'").await {
Ok(_) => {
tokio::time::sleep(Duration::from_millis(500)).await;
self.wait_for_load().await;
match self.page_info().await {
Ok(info) => BrowserResponse::ok(info),
Err(e) => {
BrowserResponse::err(format!("Back succeeded but page info failed: {e}"))
}
}
}
Err(e) => BrowserResponse::err(format!("Back failed: {e}")),
}
}
// ── Helpers ────────────────────────────────────────────────────────
/// Poll until document.readyState is 'complete' or 'interactive'.
async fn wait_for_load(&self) {
for _ in 0..PAGE_LOAD_MAX_POLLS {
if let Ok(val) = self.cdp.run_js("document.readyState").await {
let state = val.as_str().unwrap_or("");
if state == "complete" || state == "interactive" {
return;
}
}View on GitHub (pinned to acf2587e46)
Solutions
- Retry the back command — page_info usually succeeds once the load settles.
- Increase settle time before relying on the result: run a wait on document.readyState or a known selector of the previous page, then call read_page/page_info separately.
- Check the inner {e}: 'Execution context was destroyed' means wait longer after history.back(); connection errors mean re-establish the CDP session.
- If the page redirects, wait for the final URL to stabilize before requesting page info.
- Catch this error and treat the navigation as successful-but-unverified; re-query page state with a dedicated command instead of failing the whole step.
Example fix
// before: assume back gives info atomically
let resp = browser.cmd_back();
// after: tolerate partial failure and re-query
let resp = match browser.cmd_back() {
r if r.is_err() && r.err().contains("page info failed") => {
browser.wait_for_load().await;
browser.page_info_command() // retry info separately
}
r => r,
}; Defensive patterns
Strategy: fallback
Validate before calling
let ready = browser.cmd_run_js("document.readyState");
if ready.is_err() { /* context not evaluable yet — do not call back() yet, or expect info retry */ } Type guard
fn is_back_info_failure(resp: &BrowserResponse) -> bool {
resp.error.as_deref().map(|e| e.starts_with("Back succeeded but page info failed")).unwrap_or(false)
} Try / catch
match browser.cmd_back() {
Ok(info) => info,
Err(e) if e.contains("page info failed") => {
wait_for_load();
browser.read_page() // navigation succeeded; re-fetch info
}
Err(e) => Err(e),
} Prevention
- Treat this as partial success: navigation happened, only introspection failed — retry info, not the back action.
- Avoid stacking back() calls faster than pages can settle; wait for readyState between steps.
- Watch for pages that redirect on load; wait for URL stability before reading page info.
- Use a known selector of the destination page as a readiness signal before requesting info.
- Log the inner error to distinguish context-destroyed (timing) from connection-lost (session) causes.
When it happens
Trigger: The execution context is destroyed or busy while the navigated page is still loading (page_info's run_js fails), the new document crashed, the CDP connection dropped between the back() call and page_info(), or the previous page has a beforeunload/redirect that invalidates the context during evaluation.
Common situations: Going back to a heavy page that takes >500ms+poll window to reach an evaluable state; returning to a page that immediately redirects (context destroyed mid-eval); flaky CDP sessions in long-running automation; cross-origin previous page with a crash-prone script.
Related errors
- Back failed: {e}
- Navigate failed: {e}
- Navigate succeeded but page info failed: {e}
- Timed out waiting for selector: {selector} ({max_ms}ms)
- JS execution failed: {e}
AI-assisted analysis of RightNow-AI/openfang@acf2587e46 (2026-09-02).
Data as JSON: /api/errors/828ac4cbda328036.
Report an issue: GitHub.