Skip to content

fix: Browser tab updates stall the Gateway - #159599

Merged
steipete merged 3 commits into
mainfrom
codex/browser-tab-worker-store-20260927
Sep 27, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/browser-tab-worker-store-20260927

Conversation

@steipete

@steipete steipete commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Gateway event-loop stalls when Browser tab activity waits for the shared SQLite writer. An observed tab-touch write blocked the main thread for about 845 ms.

User Impact

Browser tab tracking, dashboard retention, and cleanup use the existing database workers. Stored rows, limits, retention, configuration, and the public SDK remain unchanged; no migration or operator action is required.

Why This Change Was Made

The complete Browser tab-state caller family now uses the existing V2 observation/comparison store. Live authority is checked at worker admission, comparisons retry only known conflicts, and aliases publish from accepted rows. Private per-tab admission orders fresh ownership reads and synchronous close dispatch with local mutations, releasing before the network response. Dashboard registration advertises its attempt as soon as the open response supplies native identity; this does not make remote page creation and the transport response atomic. Registration and close preserve both admission orders, and service shutdown joins accepted writes, closes, and row retirement.

The additional private code handles these asynchronous ownership boundaries within the existing runtime operation owner. It also keeps committed registration out of creation compensation, discards obsolete read preparation while propagating current-owner errors, and permits a later read to retry a failed initialization. Volatile cleanup captures the registrations owned when cleanup is invoked, before worker preparation, and never adopts replacements installed while it waits. Lifecycle capture visits only requested sessions; sweeps keep their combined durable/volatile cap policy. Runtime-free cleanup preserves immediate supplied-close dispatch. No second durable store or background manager is introduced.

Evidence

The actual Browser tool adapter with a real worker-backed SQLite store changed from 43 host-thread SQL statements to zero, with the same persisted activity result. Baseline statements included plugin-state reads/writes, transaction statements, and configuration reads. This proves removal of the host SQL boundary; it is not a production latency measurement.

The original cutover passed 697 distinct cases across 29 files, covering tool/transport/node-host callers, dashboard retention, alias recovery, runtime replacement, and cleanup. Deterministic negative controls reproduced the host-SQL path, premature shutdown, post-commit compensation, stale-read and initialization failures, and both dashboard registration/close races. The close-ordering proof uses the public Playwright entry points, an already-existing synthetic native target, real worker reads/writes, and held transport replies; unrelated tab activity remains independent.

The final head eacb73e6878c47ffce577b4c54b975475e9e3c4d passed a fresh canonical full build and strict package verification in 510.696 s. A fresh published 2026.9.4 updater installed that exact 2026.9.6 candidate in an isolated cell. Existing v1 tab rows matched their original digest before modification; public alias-based untracking removed only the intended row and preserved an opaque sentinel. An accepted public dashboard registration became durable before immediate service shutdown returned, with its subscription closed. The whole cell took 70.679 s, including 46.551 s reported by the updater and 2.448 s for the installed Browser probe. Final package and updater run.

The package's recorded commit and complete source tree match the reviewed head. Its SHA-256 is 10327cb6cf7d337f3febe316fb1375eccb5921abd471f2479f083eaaad16322c. The Browser probe used the installed public facade and real SQLite worker with a synthetic registration host; it did not exercise Chromium, CDP, a live operator Gateway, or an in-flight close. The updater independently passed its staged Gateway canary. Synthetic loopback Doctor advice and skipped host-service reconciliation were expected for this isolated manual-restart cell. Remote diagnostic publication and runner-portal synchronization reported infrastructure warnings after successful commands; hash-verified receipts were recovered and the unchanged canonical diagnostic sanitizer succeeded locally. All command processes joined and the lease completed.

The full original cutover received a clean independent P0–P2 review. Integration reviews raised two findings, both rejected after source comparison by the implementation and lead reviewers: close before the open response supplies identity, and process-local volatile tracking without invocation-runtime binding. Both behaviors already exist on the pinned main source; neither is newly introduced here. The reports and reasons are retained.

The refresh onto d86796f25b36 preserves upstream Browser caller simplifications and passed 155 distinct cases in eight affected dashboard, registration, transport, and node-host files. The first integration run exposed an order-dependent test assertion: keyed-store iteration uses its own creation timestamp and then key, so sequential registrations can tie even when payload timestamps differ. The corrected assertion preserves exact five-target multiplicity, removal count, scan bound, and retained rows without imposing an unrelated cross-key close order. Its 52-case whole file passed in 29.213 s; the 103 unaffected sibling passes were reused. Production/test types passed in 45.631/80.728 s on the integrated source. A required explicit string comparator then corrected the test’s lint failure without changing production or its assertion contract. Final typed lint, formatting, all three line/assertion ratchets, and diff checks passed on the comparator-corrected source (141.202 s total; 323.107 s including remote setup). All owned command descendants joined, and the native Testbox leases were stopped.

CI exposed two additional boundaries: runtime-backed cleanup selected volatile registrations after asynchronous preparation, and a complete runtime-env test mock omitted the newly consumed logger export. The original two-file envelope reproduced all six CI failures. Cleanup now retains invocation-time registration custody, while the partial mock preserves real runtime exports. Two new actual-worker-read cases each failed on the original production code by closing a replacement registration; both pass after the repair. The existing no-runtime replacement assertions remain unchanged.

The exact repaired source passed 75 distinct cases across eight files, including the original 31-case envelope, eight lifecycle cases, and 36 native cleanup/shutdown siblings. Fresh independent P0–P2 review was scoped-clean. Production/test types, typed lint, formatting, all three line/assertion ratchets, and diff checks passed. Selected checks took 396.040 s including the intended negative control; the clean remote installation and complete wrapper took 620.524 s. All command descendants joined and the Testbox lease stopped. The final exact-head package/updater cell above also passed. Exact-head CI completed with 55 successful jobs, 21 skipped jobs, and zero failures; the required openclaw/ci-gate passed.

Measured test costs and validation scope

Original-cutover standalone commands use pnpm test <file> --maxWorkers=1. The repaired lifecycle and runtime-lifecycle files use the equivalent supported node scripts/run-vitest.mjs <file> --maxWorkers=1 wrapper on Linux Node 24.19. Wall times include wrapper startup; earlier rows are retained unchanged-input evidence, and the integrated dashboard whole-file cost is given above. The exact-head hosted extensions bundle job passed in 178 s; production/test typing and the extension lint/boundary jobs also passed.

File Cases Wall
browser-dashboard.concurrency.test.ts 25 12.960 s
browser-dashboard.test.ts 52 22.690 s
plugin-registration.dashboard-discovery.test.ts 8 32.537 s
session-tab-registry.sqlite.test.ts 26 22.985 s
session-tab-registry.lifecycle-retry.test.ts 8 22.173 s
runtime-lifecycle.unhandled-rejections.test.ts 5 19.653 s
session-tab-registry.concurrent.test.ts 2 15.494 s
session-tab-registry.test.ts 26 2.619 s
browser-maintenance.cold.test.ts 1 13.795 s
browser-maintenance.transport.test.ts 1 11.461 s
plugin-registration.session-access.test.ts 1 12.514 s
plugin-registration.shutdown.test.ts 1 14.071 s
index.test.ts 17 20.203 s
browser/cdp.test.ts 33 17.834 s
browser/server-context.tab-selection-state.test.ts 18 11.314 s
session-tab-registry.extension-cleanup.test.ts 6 11.760 s
session-browser-dashboard.test.ts 12 9.205 s
browser-tool-session-tabs.test.ts 1 10.909 s
node-host/invoke-browser.test.ts 32 16.852 s
node-host/invoke-browser.admission.test.ts 11 13.593 s

The two new held-worker-read replacement cases took 287/185 ms within the 2.485 s lifecycle file; the runtime-lifecycle file took 0.698 s inside its wrapper. The original 31-case envelope took 24.766 s and the 36 native siblings 34.780 s. The known/unidentified close-first cases took 403/351 ms; native-read registration-first took 63/61 ms and post-open preparation-first 59/67 ms. Failed initial-read recovery took 652 ms; accepted-registration shutdown took 322 ms and cold-close/retirement shutdown 330 ms. The async activity-error case took 13 ms. The original host-SQL baseline failed its intended assertion, and the final zero-host-SQL case passed. Initial worker preparation on the constrained filesystem made an earlier two-case wrapper take 536.104 s, including 138.971 s of worker preparation; that is not steady-state test or product latency.

Selected validation includes core and Browser production/test typing, typed lint, all three dead-export scans, script lint, Doctor/plugin/import/storage guards, formatting, and line/assertion ratchets. Proof from unchanged inputs was reused; this is not a claim that the entire repository test suite ran.

Move Browser tab tracking, dashboard retention, and cleanup onto the existing worker-backed comparison store. Preserve live authority, registration/close ordering, and accepted-operation settlement without changing stored rows or retention.
Preserve worker-backed tab authority and registration ordering while applying the current dashboard caller simplifications. Compare exact removed target membership without imposing order across independent keys whose store timestamps can tie.
@clawsweeper

clawsweeper Bot commented Sep 27, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: browser size: XL labels Sep 27, 2026
@steipete
steipete marked this pull request as ready for review September 27, 2026 10:54
@steipete steipete self-assigned this Sep 27, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 27, 2026, 8:27 AM ET / 12:27 UTC (Revision 3).

ClawSweeper review

What this changes

Moves Browser tab tracking, dashboard retention, and cleanup to the SQLite worker store so those operations do not run SQLite work on the Gateway main thread.

Merge readiness

✅ Ready for maintainer review

Current main and the latest release still use synchronous Browser tab-state writes, so this PR remains useful. The prior review’s exact-head upgrade request is addressed in the updated PR evidence; no introduced blocking defect was established.

Priority: P2
Reviewed head: eacb73e6878c47ffce577b4c54b975475e9e3c4d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has focused boundary and upgrade evidence, green exact-head CI, and no established blocking finding.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The member-authored PR is exempt from the external contributor proof gate. Its body describes an exact-head installed public Browser facade using a real SQLite worker, retained-row upgrade, and shutdown result; the linked Testbox workflow was cancelled after those reported commands, and raw logs could not be retrieved through this review network. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from the external contributor proof gate. Its body describes an exact-head installed public Browser facade using a real SQLite worker, retained-row upgrade, and shutdown result; the linked Testbox workflow was cancelled after those reported commands, and raw logs could not be retrieved through this review network. No stored-data contract changes.
Evidence reviewed 9 items Current-main behavior: Current main opens the canonical Browser tab namespace through the synchronous keyed store; tab touch calls its update path.
Current-main caller: The current-main tab-touch function calls the synchronous tab update.
Release check: The latest release, v2026.9.6, also opens the tab namespace synchronously; this fix has not shipped there.
Findings None None.
Security None None.

How this fits together

The Browser plugin receives tool activity, dashboard requests, and session lifecycle events. It stores tab ownership in plugin SQLite, then uses that state to retain dashboard pages and close eligible tabs.

flowchart LR
  A[Browser tool activity] --> C[Tab tracking]
  B[Dashboard and session events] --> C
  C --> D[SQLite worker store]
  D --> E[Current ownership check]
  E --> F[Retained page or close request]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +797, Tests +859, Docs +5. Total +1661 across 43 files.

View PR surface stats
Area Files Added Removed Net
Source 20 1528 731 +797
Tests 22 1371 512 +859
Docs 1 12 7 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 43 2911 1250 +1661

Review metrics

Metric Value Why it matters
Code growth by surface production +797, test and CI +859 lines net The PR body explains the production growth as private admission, ordering, and settlement work for the asynchronous cutover.

Technical review

Best possible solution:

Keep the worker-backed Browser tab path while preserving existing v1 rows, dashboard close authority, and settlement during service shutdown.

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

Yes at the source boundary: current main routes Browser tab touch through a synchronous keyed-store update. This read-only review did not independently time the reported stall.

Is this the best way to solve the issue?

Yes. The branch uses the existing worker comparison store and retains the tab namespace and row format, with focused checks for ownership and cleanup ordering.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 69809d7a9427.

Labels

Label changes:

  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: Browser tab activity can stall the Gateway event loop, with the reported impact limited to this workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored PR is exempt from the external contributor proof gate. Its body describes an exact-head installed public Browser facade using a real SQLite worker, retained-row upgrade, and shutdown result; the linked Testbox workflow was cancelled after those reported commands, and raw logs could not be retrieved through this review network. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • FMLS: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-27T11:00:24.683Z sha 532efb5 :: blocked before merge. :: none
  • reviewed 2026-09-27T12:03:31.523Z sha eacb73e :: blocked before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

The final-head package/upgrade gap is now closed for eacb73e6878c47ffce577b4c54b975475e9e3c4d. The canonical full build and strict package verification passed (510.696 s); the published 2026.9.4 updater installed that exact candidate, preserved the existing v1 tab rows, removed only the intended row through public alias untracking, and settled an accepted dashboard registration durably before service shutdown returned (70.679 s total cell). Package/updater run.

Exact-head CI is green: 55 successful jobs, 21 skipped, zero failed. The PR body now records final-source identity, measured costs, infrastructure warnings, and the limits of the synthetic installed-public-facade proof. No source or head change was needed.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 27, 2026
@steipete
steipete merged commit 08bf4b2 into main Sep 27, 2026
137 of 139 checks passed
@steipete
steipete deleted the codex/browser-tab-worker-store-20260927 branch September 27, 2026 12:36
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
* fix: Browser tab updates stall the Gateway

Move Browser tab tracking, dashboard retention, and cleanup onto the existing worker-backed comparison store. Preserve live authority, registration/close ordering, and accepted-operation settlement without changing stored rows or retention.

* fix(browser): preserve cleanup registration custody
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 extensions: browser P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant