Skip to content

fix(browser): time out remote tab enumeration - #80147

Merged
steipete merged 5 commits into
openclaw:mainfrom
HemantSudarshan:hemant/issue-triage-20260509
Jul 5, 2026
Merged

steipete merged 5 commits into
openclaw:mainfrom
HemantSudarshan:hemant/issue-triage-20260509

Conversation

@HemantSudarshan

@HemantSudarshan HemantSudarshan commented May 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Problem

Remote CDP profiles use a persistent Playwright connection for tab listing because HTTP /json/list is ephemeral for those providers. When that Playwright-backed enumeration stalls, browser requests can hang behind the stuck CDP operation instead of failing fast.

Root Cause

createProfileTabOps().readTabs() passed only cdpUrl and SSRF policy to listPagesViaPlaywright(). The lower-level Playwright enumeration path had no operation-level timeout around connectBrowser(), getAllPages(), or per-page target/title/url reads, and a stuck scoped connection could remain cached or in-flight.

Architectural Reasoning

The fix reuses the existing browser remote CDP timeout contract rather than adding a new config key. Remote tab listing now uses max(remoteCdpTimeoutMs, remoteCdpHandshakeTimeoutMs), which matches the existing distinction between HTTP discovery and WebSocket handshake budgets. Timeout cleanup goes through the existing scoped Playwright disconnect helper, preserving per-CDP URL isolation and avoiding hidden coupling to other browser profiles.

Real behavior proof

  • Behavior or issue addressed: Remote CDP Playwright tab enumeration now returns a bounded timeout error instead of waiting indefinitely on a stalled CDP discovery/enumeration path.
  • Real environment tested: Windows 11 worktree, Node v22.15.0, pnpm 10.33.2, branch hemant/issue-triage-20260509, commit 9aba9b405ae5c4601211fd0b2b428d9640425b8b.
  • Exact steps or command run after this patch: Started a real loopback HTTP endpoint that accepts CDP discovery connections and deliberately never responds; called production listPagesViaPlaywright() through node --import tsx with timeoutMs: 100 and an SSRF policy allowing loopback/private access; closed the scoped Playwright connection and destroyed the held socket after the call.
  • Evidence after fix:
$ node --import tsx - < hanging-cdp-smoke.mjs
{"ok":true,"error":"Playwright page enumeration timed out after 100ms","elapsedMs":309}
  • Observed result after fix: The production browser module returned Playwright page enumeration timed out after 100ms and the script exited cleanly instead of hanging on the held CDP request.
  • What was not tested: I did not use a real remote Chrome host because the failure mode is a stalled CDP endpoint; the local loopback endpoint exercises the same production timeout path with deterministic cleanup. Full pnpm test extensions/browser still has unrelated Windows environment failures noted below.

Testing

  • pnpm test extensions/browser/src/browser/pw-session.connections.test.ts extensions/browser/src/browser/server-context.remote-profile-tab-ops.playwright.test.ts
  • pnpm exec oxfmt --check --threads=1 extensions/browser/src/browser/pw-session.ts extensions/browser/src/browser/server-context.tab-ops.ts extensions/browser/src/browser/pw-session.connections.test.ts extensions/browser/src/browser/server-context.remote-profile-tab-ops.playwright.test.ts
  • pnpm tsgo:extensions from O:\ subst drive to avoid the repo path-with-spaces launcher bug
  • pnpm tsgo:extensions:test from O:\
  • pnpm lint:extensions from O:\
  • pnpm check:changelog-attributions
  • git diff --check upstream/main...HEAD
  • pnpm check:changed --staged exited 0 with no lane output

Full pnpm test extensions/browser was also run locally. It failed on unrelated Windows environment assumptions: local browser auto-detection / missing supported browser launch fixtures and existing /tmp path expectations being normalized to C:\tmp. The two touched regression test files pass.

Risk Analysis

Risk is medium because this touches async browser/CDP lifecycle behavior. The change is scoped to remote Playwright tab enumeration, does not alter local managed browser JSON tab listing, and does not change navigation, action, or screenshot behavior. On timeout, OpenClaw drops only the scoped Playwright connection for that CDP URL and leaves the actual remote browser tabs intact.

Backward Compatibility

No config, API, or response-shape changes. Existing browser.remoteCdpTimeoutMs and browser.remoteCdpHandshakeTimeoutMs now also bound remote Playwright tab enumeration.

Screenshots / Logs

The real behavior proof above is terminal output from the after-fix smoke; no UI screenshot is applicable.

@openclaw-barnacle openclaw-barnacle Bot added size: M proof: supplied External PR includes structured after-fix real behavior proof. labels May 10, 2026
@clawsweeper

clawsweeper Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 05618e511a01649ee72387adcf575023fadd7c24, but the PR head is now f159863c6bb9fbe045ef7e80288cc15c89e0028c. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (7 earlier review cycles)
  • reviewed 2026-07-04T03:45:42.939Z sha abf9c793dd95fb17e0852dfc87bfdc85ebd801ab :: needs changes before merge. :: [P2] Prevent late connects from recaching timed-out browsers | [P2] Document the expanded remote CDP timeout contract | [P3] Remove the release-owned changelog edit
  • reviewed 2026-07-05T19:35:53.734Z sha 6bb7a1825fa65f763fad883438ad279ca67f9a3f :: needs changes before merge. :: [P2] Clamp the enumeration timeout before scheduling it | [P3] Use const for the stuck-page context | [P3] Avoid returning from the Promise executor | [P3] Remove the release-owned changelog entry
  • reviewed 2026-07-05T19:55:24.894Z sha 43f93f8e8971daffab9d8cdfbc7ac69a2d49ff72 :: needs changes before merge. :: [P2] Clamp the enumeration timeout before scheduling it | [P3] Remove the release-owned changelog entry
  • reviewed 2026-07-05T20:19:17.478Z sha ef0cc1e52e4f183ceae852dd796c77c8b52eb063 :: needs changes before merge. :: [P2] Clamp the enumeration timeout before scheduling it | [P3] Remove the release-owned changelog entry
  • reviewed 2026-07-05T20:46:02.604Z sha 59619711e8bfa4efc365ab578679d4a44b5a14b8 :: needs changes before merge. :: [P2] Clamp the enumeration timeout before scheduling it | [P3] Remove the release-owned changelog entry
  • reviewed 2026-07-05T22:28:40.787Z sha 717a6e5f9564e32987ea110a2154a6cd27f7f494 :: needs changes before merge. :: [P2] Clamp the enumeration timeout before scheduling it | [P3] Remove the release-owned changelog entry
  • reviewed 2026-07-05T23:22:42.462Z sha bc9e74ce2adcb14b4164d34574a1814257d09bb0 :: needs changes before merge. :: [P2] Clamp the enumeration timeout before scheduling it | [P3] Remove the release-owned changelog entry

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@HemantSudarshan
HemantSudarshan force-pushed the hemant/issue-triage-20260509 branch from 9aba9b4 to b7833e6 Compare May 18, 2026 05:15
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 18, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. P1 High-priority user-facing bug, regression, or broken workflow. impact:crash-loop Crash, hang, restart loop, or process-level availability failure. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 18, 2026
@HemantSudarshan
HemantSudarshan force-pushed the hemant/issue-triage-20260509 branch from b7833e6 to abf9c79 Compare May 18, 2026 05:34
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 18, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 18, 2026

Copy link
Copy Markdown
Contributor Author

Updated this branch to current main at head abf9c793dd95fb17e0852dfc87bfdc85ebd801ab.

What changed after the ClawSweeper review:

  • Rebased the browser timeout fix onto current main.
  • Preserved the current-main isSelectableCdpBrowserTarget filter before results.push in listPagesViaPlaywright and kept the caller-side filter.

Validation run at the new head:

  • node scripts/run-vitest.mjs extensions/browser/src/browser/pw-session.connections.test.ts extensions/browser/src/browser/server-context.remote-profile-tab-ops.playwright.test.ts
  • pnpm exec oxfmt --check --threads=1 extensions/browser/src/browser/pw-session.ts extensions/browser/src/browser/server-context.tab-ops.ts extensions/browser/src/browser/pw-session.connections.test.ts extensions/browser/src/browser/server-context.remote-profile-tab-ops.playwright.test.ts CHANGELOG.md
  • git diff --check upstream/main...HEAD

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 2, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 2, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. impact:crash-loop Crash, hang, restart loop, or process-level availability failure. labels Jun 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 15, 2026
@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Jun 29, 2026
@steipete
steipete force-pushed the hemant/issue-triage-20260509 branch from e71c197 to 717a6e5 Compare July 5, 2026 22:17
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: slack Channel integration: slack app: android App: android app: ios App: ios app: web-ui App: web-ui scripts Repository scripts commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling channel: irc extensions: openai extensions: minimax extensions: qa-lab extensions: codex extensions: google size: XL labels Jul 5, 2026
@steipete
steipete force-pushed the hemant/issue-triage-20260509 branch from 717a6e5 to bc9e74c Compare July 5, 2026 23:12
@steipete
steipete force-pushed the hemant/issue-triage-20260509 branch from bc9e74c to fe7139e Compare July 5, 2026 23:29
@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

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

Labels

docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: supplied External PR includes structured after-fix real behavior proof. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

browser: listPagesViaPlaywright lacks timeout protection, causing all HTTP requests to 500 when CDP connection hangs

3 participants