Skip to content

fix(browser): report crashed tabs explicitly instead of a generic timeout - #194690

Closed
xiaopan-xydt wants to merge 5 commits into
openclaw:mainfrom
xiaopan-xydt:osp-194667
Closed

xiaopan-xydt wants to merge 5 commits into
openclaw:mainfrom
xiaopan-xydt:osp-194667

Conversation

@xiaopan-xydt

@xiaopan-xydt xiaopan-xydt commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #194667

What Problem This Solves

When a tab's renderer process dies (kernel OOM kill or crash), the managed browser keeps running, but every action on that tab reports misleading failures: snapshot hangs ~20 s and fails with the generic transient hint ("the browser is currently unavailable"), screenshot/navigate fail with raw Playwright text ("Target crashed"), and tabs still lists the dead tab as a normal entry. An agent retries the dead tab, then tells the user the whole browser is down — when only one tab died.

Plain language: the browser did not go down; one tab's rendering process was killed. The tool had no way to tell the two apart, so it gave a wrong diagnosis. Now every action on a dead tab says exactly that: the tab crashed, open the URL in a new tab — and tabs marks the dead tab.

Why This Change Was Made

The browser tool had no notion of a crashed renderer. Playwright emits a crash event on the Page object, but nothing listened, so crash-shaped failures fell through to the generic timeout classifier. The fix records crashed pages (a page-scoped WeakSet wired into the existing per-page state bootstrap), refuses a known-crashed target during resolution before any action runs, translates mid-action "Target crashed" failures at the shared awaitActionWithAbort boundary, and marks crashed entries in tab listings.

Per review, three adjustments: close remains available for crashed targets (target resolution takes an allowCrashed admission flag, so the cleanup operation keeps its ownership checks); crash facts learned on the Playwright side (getPageForTargetId refusal and Playwright target enumeration) flow into a target-keyed registry that raw /json/list listings also consume, and the CLI renders the marker; the crash test fixture keeps a correctly typed emitter, with action-boundary regressions replacing translator-only tests.

User Impact

Agents see one explicit error for every action on a crashed tab — fast, without the "browser is unavailable" retry hint — and can recover by opening the URL in a new tab. Tab listings (JSON and CLI output) distinguish a dead tab from a live one, and closing a crashed tab still works.

Evidence

Real runtime runs on the main tree this change is based on (every changed file byte-compared as main/head + exactly this delta before push):

Check Result
pw-session-crashed-target.test.ts: crash-event marking; "Target crashed" translation incl. non-Error form; no false translation for locator timeout or genuine close; action-boundary: crashed rejection → explicit error, timeout and close-shaped failures unchanged 5/5 green
Red checks: crash listener removed → marking test fails; action-boundary wiring reverted → boundary test fails (earlier round); fixture-typing round rerun green confirmed
Adjacent pw-session.connections.test.ts (incl. connection scoping with the new admission flag), pw-session-navigation-fence.test.ts 44/44 green
tsc --noEmit -p tsconfig.extensions.json: zero errors under extensions/browser verified

AI Assistance

This PR is AI-assisted. Used grep and git diff to analyze issue #194667, locate the missing crash handling in the browser tool's session layer, and implement the fix. The implementer understands the code: Playwright's per-page crash event marks the dead page, target resolution refuses it (close opts out via allowCrashed), and the shared action boundary translates "Target crashed" failures. All evidence above is from real local runtime execution.

…eout

Every action on a tab whose renderer died now fails fast with "tab crashed
(renderer exited); open the URL in a new tab": a page-scoped crash mark from
the Playwright crash event refuses the target before any action, mid-action
"Target crashed" failures translate at the shared action boundary, and tabs
mark crashed entries.
@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@xiaopan-xydt
xiaopan-xydt marked this pull request as ready for review November 7, 2026 16:37
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 7, 2026
@wr-web

wr-web commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Independent live Page.crash run for #194667, comparing both open PRs against main. I am not opening a competing PR.

Setup:

  • Windows 11, Node v26.12.1, Google Chrome (managed openclaw profile, headless).
  • Source Gateway on loopback with isolated state.
  • browser open http://127.0.0.1:28798/ gives target T; then CDP Page.crash is sent to ws://127.0.0.1:<cdpPort>/devtools/page/T; then each CLI action below.
  • Times are whole CLI invocations. About 17.5 s of each is CLI startup on this host, so a fast failure shows as roughly 17.5 s.
Action on crashed T main c3b92c2 #194690 56ae7ba #194682 906d205
snapshot 27.7 s, page.ariaSnapshot: Target crashed 22.4 s, tab crashed (renderer exited); open the URL in a new tab 19.9 s, The tab crashed or stopped responding…open the page again in a new tab…
screenshot 17.7 s, page.screenshot: Target crashed 17.6 s, tab crashed (renderer exited)… 17.9 s, The tab crashed or stopped responding…
navigate ❌ 47.5 s, browser request timed out ✅ 17.5 s, tab crashed (renderer exited)… ❌ 47.6 s, browser request timed out
tabs (text output) T listed as a normal page T listed as a normal page T listed as a normal page
open new tab works works works

proof-194667

For this PR (#194690): all three page actions on the crashed tab (snapshot, screenshot and navigate) now fail fast with the explicit tab-scoped error, and the browser stays usable for new tabs. The human-readable tabs text output did not show a crash marker in this run. I only checked the text output, not --json, so the crashed: true field may still be present there.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR tracks crashed browser pages, returns tab-specific recovery errors, and adds crash markers to tab listings.

Example: Chrome target T crashes while another tab remains healthy.

  • Before: Navigation can time out or report raw Playwright errors, suggesting the browser is unavailable.
  • After: An observed crashed target returns “tab crashed (renderer exited); open the URL in a new tab”.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful direction with credible earlier runtime evidence, but four concrete correctness gaps and incomplete proof for the later behavior prevent readiness.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) 4 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A single crashed renderer produces browser-wide recovery advice and remains indistinguishable from healthy tabs.
Reason: Accurate tab-scoped diagnostics have demonstrated user value and fit the existing browser plugin without new settings or capabilities.

Merge readiness

⛔ Blocked before merge - 5 items remain

This PR addresses a real browser diagnostic bug, but crashed-tab closure and crash-marker delivery remain incomplete, and the error matcher can misclassify ordinary locator timeouts.

Priority: P2
Reviewed head: cf2557ee726085c524bb9cceb6d9a1182e4ebc74

Before merge

  • Add real behavior proof - The inspected wr-web screenshot and live report establish earlier-head snapshot, screenshot, navigation, and new-tab behavior through the shipped CLI, but do not exercise the subsequent close exception or raw-listing and CLI-marker changes; those later paths need contributor runtime evidence with IPs, keys, phone numbers, and non-public endpoints redacted. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Allow crashed targets through the complete action-close path (P2) - The prior close finding is only partly resolved. POST /act with kind=close first enters runActionExecution, whose getPageForTargetId call omits allowCrashed; closePageViaPlaywright also omits it. A known crashed target therefore throws here before either close owner runs, including the CLI close command without an explicit target. The exception added to closePageByTargetIdViaPlaywright covers only the separate tab-management path. Carry close admission through both action resolutions while retaining the existing ownership checks.
  • Publish observed crashes before raw managed-tab listings (P2) - After a managed page has been resolved normally, let it emit crash and immediately list tabs without another action on that target. The listener updates only crashedPages. Local managed profiles use raw /json/list rather than listPagesViaPlaywright, and the new lookup reads crashedTargetsByCdpUrl, which remains empty until a later refused action. Thus both JSON and CLI listings still present this already-observed dead tab normally. Connect the crash event to the target identity already owned by the page lifecycle instead of requiring a failed action to publish the fact.
  • Preserve the crash marker in agent tab results (P2) - Even when browserTabs returns crashed:true, formatAgentTab reconstructs the record without that field, and executeTabsAction uses this projection for both model-visible text and result details. The agent therefore cannot distinguish the crashed tab despite the new BrowserTab contract. Forward the marker through this existing projection and cover it in browser-tool.tabs.test.ts. This omission was visible at the earlier reviewed head and was missed in that review.
  • Match crash failures without searching locator call logs (P2) - On a healthy page without the requested text, an action such as {kind:"wait",text:"Target crashed",timeoutMs:500} rejects with a locator timeout whose Playwright call log includes getByText('Target crashed'). Searching the entire message matches that locator text and replaces the actual timeout with advice to abandon a supposedly crashed tab. Parse the Playwright failure headline rather than matching arbitrary call-log content, and retain the original failure otherwise. The matcher is unchanged from the earlier reviewed head; this false-positive case was missed previously.

Findings

  • [P2] Allow crashed targets through the complete action-close path — extensions/browser/src/browser/pw-session-connection.ts:593-598
  • [P2] Publish observed crashes before raw managed-tab listings — extensions/browser/src/browser/server-context.tab-ops.ts:251-253
  • [P2] Preserve the crash marker in agent tab results — extensions/browser/src/browser-tool-dispatch.ts:106-110

Tests

  • Low-value test extensions/browser/src/browser/pw-session-crashed-target.test.ts: Remove the translator-only cases duplicated by the action-boundary cases, carrying useful non-Error and error-metadata assertions into the boundary tests.
  • Missing end-to-end proof: Supply redacted terminal output or screenshots after the fixes showing Page.crash followed directly by managed CLI and agent tab listings plus successful /act closure; the existing live run predates those changes.
Agent review details

How this fits together

The browser plugin resolves browser targets, executes Playwright operations, and projects tab metadata and errors into HTTP responses, CLI output, and agent tool results.

flowchart LR
  A[CLI or agent] --> B[Browser routes]
  B --> C[Target resolution]
  C --> D[Playwright page]
  D --> E[Crash observation]
  E --> F[Tab metadata and errors]
  F --> A
Loading

Technical review

Best possible solution:

Complete crash handling in the existing page lifecycle and action owners, preserve closure, and carry the same crash fact through raw listings and agent output.

Do we have a high-confidence way to reproduce the issue?

The official-release report provides a deterministic CDP Page.crash sequence, independent live evidence confirms the mechanism, and current-main source still lacks crash admission; this review did not execute the reproduction.

Is this the best way to solve the issue?

The lifecycle-based approach is appropriate, but the close exception and crash-state projections must cover all existing consumers, and crash classification must distinguish Playwright failure headlines from locator call-log content.

Full review comments:

  • [P2] Allow crashed targets through the complete action-close path — extensions/browser/src/browser/pw-session-connection.ts:593-598
    The prior close finding is only partly resolved. POST /act with kind=close first enters runActionExecution, whose getPageForTargetId call omits allowCrashed; closePageViaPlaywright also omits it. A known crashed target therefore throws here before either close owner runs, including the CLI close command without an explicit target. The exception added to closePageByTargetIdViaPlaywright covers only the separate tab-management path. Carry close admission through both action resolutions while retaining the existing ownership checks.
    Confidence: 0.99
  • [P2] Publish observed crashes before raw managed-tab listings — extensions/browser/src/browser/server-context.tab-ops.ts:251-253
    After a managed page has been resolved normally, let it emit crash and immediately list tabs without another action on that target. The listener updates only crashedPages. Local managed profiles use raw /json/list rather than listPagesViaPlaywright, and the new lookup reads crashedTargetsByCdpUrl, which remains empty until a later refused action. Thus both JSON and CLI listings still present this already-observed dead tab normally. Connect the crash event to the target identity already owned by the page lifecycle instead of requiring a failed action to publish the fact.
    Confidence: 0.99
  • [P2] Preserve the crash marker in agent tab results — extensions/browser/src/browser-tool-dispatch.ts:106-110
    Even when browserTabs returns crashed:true, formatAgentTab reconstructs the record without that field, and executeTabsAction uses this projection for both model-visible text and result details. The agent therefore cannot distinguish the crashed tab despite the new BrowserTab contract. Forward the marker through this existing projection and cover it in browser-tool.tabs.test.ts. This omission was visible at the earlier reviewed head and was missed in that review.
    Confidence: 1
    Late finding: first raised on code an earlier review cycle already covered.
  • [P2] Match crash failures without searching locator call logs — extensions/browser/src/browser/pw-session-crash-state.ts:33-38
    On a healthy page without the requested text, an action such as {kind:"wait",text:"Target crashed",timeoutMs:500} rejects with a locator timeout whose Playwright call log includes getByText('Target crashed'). Searching the entire message matches that locator text and replaces the actual timeout with advice to abandon a supposedly crashed tab. Parse the Playwright failure headline rather than matching arbitrary call-log content, and retain the original failure otherwise. The matcher is unchanged from the earlier reviewed head; this false-positive case was missed previously.
    Confidence: 0.98
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b27440329b4c.

Provenance checked

  • Playwright page lifecycle and target admission changes intended behavior with a stated reason (aba0b12: The session-manager split preserved existing lifecycle, selection, and quarantine ownership; it was not the original introduction of those behaviors.)
  • Shared interaction error propagation changes intended behavior with a stated reason (502d1cf: The interaction split retained navigation and operation policy in focused modules; the PR explicitly changes crash-shaped failures to improve diagnosis.)
  • Structured action failures keeps the original intent (a38c3ab: Ordinary action failures were separated from browser outages to avoid misleading service-unavailability guidance.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test extensions/browser/src/browser/pw-session-crashed-target.test.ts extensions/browser/src/browser/pw-session.connections.test.ts
  • pnpm test extensions/browser/src/browser/pw-tools-core.interactions.batch.test.ts extensions/browser/src/browser/pw-tools-core.snapshot.test.ts
  • pnpm test extensions/browser/src/browser/server-context.remote-profile-tab-ops.fallback.test.ts extensions/browser/src/browser/routes/tabs.test.ts
  • pnpm test extensions/browser/src/browser-tool.tabs.test.ts extensions/browser/src/cli/browser-cli-manage.test.ts
  • pnpm check:changed

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit aba0b12 adds extensions/browser/src/browser/pw-session-state.ts:38 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: aba0b12014a3; files: extensions/browser/src/browser/pw-session-state.ts)

PR surface

Source +87, Tests +69. Total +156 across 10 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 9 92 5 +87
Tests 1 69 0 +69
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 161 5 +156

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #194667
Summary: This PR and another open repair address the same renderer-crash diagnosis and tab-listing defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Renderer crashes cause misleading diagnostics and hinder tab recovery, while healthy tabs and new-tab creation remain available.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-08T05:37:49.284Z sha 56ae7ba :: needs changes before merge. :: [P2] Preserve close operations for crashed Playwright targets | [P2] Carry crash markers through managed tab listings | [P2] Emit the synthetic crash through a correctly typed fixture

Reviewed November 14, 2026, 9:37 AM ET / 14:37 UTC (Revision 2).

…raw listings

Per review: closeTab keeps working via allowCrashed admission; crash facts
learned on the Playwright side now flow into raw /json/list listings and the
CLI renders the crashed marker; the crash test fixture is correctly typed
with action-boundary regressions added.
@xiaopan-xydt

Copy link
Copy Markdown
Contributor Author

Per review, pushed 0fe12ba:

  • Close preserved for crashed targets: target resolution takes an allowCrashed admission flag; closePageByTargetIdViaPlaywright passes it, so the cleanup operation keeps its ownership checks and can remove a crashed tab.
  • Crash markers reach raw listings and the CLI: crash facts learned on the Playwright side (resolution refusal + Playwright target enumeration) now flow into a target-keyed registry that the raw /json/list tab path also consumes; the human-readable CLI tab output renders the crashed marker.
  • Typed fixture + action-boundary regressions: the crash fixture keeps a correctly typed emitter (no type erasure through double assertion), and the translator-only tests were replaced with action-boundary regressions covering crash rejection plus unchanged timeout and close-shaped failures.

Body updated with the new evidence matrix. @clawsweeper re-review

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 8, 2026
@xiaopan-xydt

Copy link
Copy Markdown
Contributor Author

Friendly ping — the fresh review requested on Nov 8 appears not to have been queued (no ack received). The current head 0fe12badeb3 is ready. @clawsweeper re-review

@xiaopan-xydt
xiaopan-xydt requested a review from a team as a code owner November 12, 2026 18:23
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 12, 2026
@xiaopan-xydt

Copy link
Copy Markdown
Contributor Author

Synced the branch with current main and restored the oxfmt import order in pw-tools-core.interactions.navigation.ts (the CI check-lint format failure). Ready for a fresh review.

@xiaopan-xydt

Copy link
Copy Markdown
Contributor Author

Merged current main into this branch to clear the conflicts. The only overlapping hunk was server-context.tab-ops.ts: main's isSelectableCdpBrowserTarget(p, options) signature change now carries this branch's p.crashed marking for relay-discovered pages. The other two touched files (pw-session-actions.ts, pw-tools-core.interactions.navigation.ts) merged cleanly. Ready for a fresh review.

@xiaopan-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the work here. We're closing this: it doesn't show a real user-facing problem (no report from an affected user and no natural reproduction), and it follows a pattern of small, speculative or duplicate changes split across many PRs. Please open an issue with a reproduction of real harm first; a fix can follow once the problem is confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: browser P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Browser tool reports a crashed tab as a generic 20 s timeout and tells the agent the browser is unavailable

3 participants