Skip to content

test(ui): drain browser context routes during cleanup - #156473

Merged
steipete merged 1 commit into
mainfrom
codex/deflake-browser-routes-round8
Sep 23, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/deflake-browser-routes-round8

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Browser contexts could close their request clients while context-owned route callbacks were still fetching responses, leaving unhandled errors after otherwise passing Control UI tests.

User Impact

No production behavior changes. Browser test cleanup now waits for its active callbacks while keeping failures and cleanup deadlines visible.

Why This Change Was Made

The shared suite already drained held page routes, but the plain-HTTP outbox proxy installs context routes. Drain both scopes before closing the context. Nine callers that bypassed managed cleanup now use the existing suite owner, and the existing native-fork regression also holds a context callback until cleanup has joined it. No retries, error suppression, longer deadlines, or weaker assertions were added.

Evidence

The original main job passed all 373 assertions but reported two unhandled font route.fetch socket errors. Before this repair, the same 78-file membership passed on frozen main e7fbe5389e0b; the historical socket failure was not reproduced. The expanded lifecycle regression independently failed on the old helper because context closure preceded callback drainage; it passes with this change and retains the original test-body error.

Remote proof on Node 24.19.0 and Playwright 1.63.0 passed:

  • Existing lifecycle suite: 15 cases, 38.40 seconds wall with pnpm test ui/src/test-helpers/control-ui-e2e-suite.test.ts --maxWorkers=1.
  • Real browser outbox suite: 9 cases, 95.16 seconds; three migrated caller files: 21 cases, 161.62 seconds.
  • Original 78-file membership, preserving its include order and three-worker configuration: 373 cases, 578.58 seconds, no unhandled errors.
  • All selected checks, including 25 core test type graphs, export scans, formatting, and lint. Fresh independent P2 review found no actionable findings.

Behavioral proof ran in Testbox 35838998797. Its remaining lifetime was too short for the serial typecheck, so six completed graphs were reused and the other 19 plus subsequent canonical checks passed in Testbox 35849809144. Both leases are stopped; cancellation of the first workflow records deliberate cleanup, not a passing overall payload. All five changed file hashes remain identical after rebasing onto main's already-landed CI repairs.

Preparation failures were retained and corrected before proof: the first baseline lacked Playwright's pinned ffmpeg and used changed timing weights that selected a different cohort; the candidate launcher initially rejected a raw-SHA changed-check base before remote execution. The successful build also reported the existing startup-bundle size advisory, which remains with its UI performance owner.

Current-head CI run 35855945310 passed. Reported module times were 74.97 seconds for the lifecycle helper in the Bun UI unit project, 18.63 seconds for model-picker refresh, and 72.49 seconds for scroll-dock. Catalog bootstrap was not selected in that PR CI run; its cases are covered by the explicit remote caller proof above.

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review September 23, 2026 11:40
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 23, 2026, 7:47 AM ET / 11:47 UTC.

ClawSweeper review

What this changes

The PR makes browser-test cleanup wait for active context routes, moves nine cleanup calls to the shared suite owner, and extends the lifecycle regression.

Merge readiness

✅ Ready for maintainer review

The repair remains necessary: current main still omits context-route drainage. No actionable correctness or security findings were found, and the supplied browser validation supports the change.

Likely related people: steipete is a medium-confidence routing candidate based on prior suite-lifecycle work.

Priority: P2
Reviewed head: 951a6ac7723bc69e69eae6ed7cfa4ad675450978

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant browser validation and a targeted regression; no blocking defects found.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The supplied Testbox evidence exercises the changed suite owner with real Playwright browsers through outbox and migrated caller scenarios, reporting clean after-fix completion; the injected lifecycle regression separately checks callback ordering and error retention. Raw linked logs were inaccessible to this reviewer. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The supplied Testbox evidence exercises the changed suite owner with real Playwright browsers through outbox and migrated caller scenarios, reporting clean after-fix completion; the injected lifecycle regression separately checks callback ordering and error retention. Raw linked logs were inaccessible to this reviewer. No stored-data contract changes.
Evidence reviewed 8 items Introduced change: The pinned introduction diff adds context.unrouteAll with wait behavior to the existing cleanup phase, migrates nine direct closes, and extends the existing regression. It adds no production behavior, dependencies, permissions, or stored-data changes.
Still needed on main: Fetched main drains held page routes before context.close but does not drain context-owned routes. The plain-HTTP outbox fixture registers context routes that await route.fetch, establishing the concrete affected lifecycle.
Real context-route consumer: The outbox plain-HTTP proxy installs a BrowserContext route, fetches the response from the local server, then fulfills the intercepted request. This is an affirmative Playwright dependency contract; no Codex runtime or protocol contract is involved.
Findings None None.
Security None None.

How this fits together

The Control UI browser-test harness owns browser contexts and intercepted requests used by UI scenarios. Its cleanup must finish active request callbacks before closing the context and releasing test resources.

flowchart TD
  A[Browser test scenarios] --> B[Shared suite cleanup]
  C[Page and context routes] --> B
  B --> D[Release held requests]
  D --> E[Wait for active callbacks]
  E --> F[Close browser context]
  F --> G[Release resources or report failure]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +29. Total +29 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 53 24 +29
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 53 24 +29

Review metrics

Metric Value Why it matters
Lifecycle regression cost 15 existing cases; 38.40 seconds reported wall time The change extends an existing native-fork case without adding another process-based scenario.

Technical review

Best possible solution:

Keep browser teardown under the existing suite owner, joining both route scopes before context closure while preserving errors and bounded cleanup.

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

Yes for the cleanup-order defect: current main closes contexts without joining their active routes, and the supplied regression exercises that ordering. The original intermittent socket failure was not reproduced; this review did not execute tests.

Is this the best way to solve the issue?

Yes. Extending the existing cleanup owner uses Playwright's supported drainage contract and avoids retries, suppression, or competing teardown logic.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a bounded browser-test cleanup defect without changing user-facing runtime behavior.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied Testbox evidence exercises the changed suite owner with real Playwright browsers through outbox and migrated caller scenarios, reporting clean after-fix completion; the injected lifecycle regression separately checks callback ordering and error retention. Raw linked logs were inaccessible to this reviewer. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The supplied Testbox evidence exercises the changed suite owner with real Playwright browsers through outbox and migrated caller scenarios, reporting clean after-fix completion; the injected lifecycle regression separately checks callback ordering and error retention. Raw linked logs were inaccessible to this reviewer. No stored-data contract changes.

Label justifications:

  • P2: This repairs a bounded browser-test cleanup defect without changing user-facing runtime behavior.
  • 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. Sufficient (linked_artifact): The supplied Testbox evidence exercises the changed suite owner with real Playwright browsers through outbox and migrated caller scenarios, reporting clean after-fix completion; the injected lifecycle regression separately checks callback ordering and error retention. Raw linked logs were inaccessible to this reviewer. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied Testbox evidence exercises the changed suite owner with real Playwright browsers through outbox and migrated caller scenarios, reporting clean after-fix completion; the injected lifecycle regression separately checks callback ordering and error retention. Raw linked logs were inaccessible to this reviewer. No stored-data contract changes.

Evidence

What I checked:

  • Introduced change: The pinned introduction diff adds context.unrouteAll with wait behavior to the existing cleanup phase, migrates nine direct closes, and extends the existing regression. It adds no production behavior, dependencies, permissions, or stored-data changes. (ui/src/e2e/control-ui-e2e-suite.test-support.ts:266, 951a6ac7723b)
  • Still needed on main: Fetched main drains held page routes before context.close but does not drain context-owned routes. The plain-HTTP outbox fixture registers context routes that await route.fetch, establishing the concrete affected lifecycle. (ui/src/e2e/control-ui-e2e-suite.test-support.ts:265, bab3136d3c60)
  • Real context-route consumer: The outbox plain-HTTP proxy installs a BrowserContext route, fetches the response from the local server, then fulfills the intercepted request. This is an affirmative Playwright dependency contract; no Codex runtime or protocol contract is involved. (ui/src/e2e/chat-outbox-payloads.test-support.ts:78, 951a6ac7723b)
  • Playwright drainage semantics: Inspected v1.63.0 browserContext.ts and network.ts: unrouteAll removes registered routes and wait mode joins active handler invocations; exception suppression belongs to ignoreErrors instead. The package manifest confirms microsoft/playwright ownership. (packages/playwright-core/src/client/network.ts:897)
  • Regression and error preservation: The extended native-fork regression holds a context callback during cleanup and checks successful callback settlement, drainage before closure, and retention of the original body error. The shared cleanup runner preserves failures while attempting subsequent cleanup phases; existing deadlines remain unchanged. (ui/src/test-helpers/control-ui-e2e-suite.test.ts:527, 951a6ac7723b)
  • Supplied browser proof: The captured PR body reports Node 24.19.0 / Playwright 1.63.0 real-browser outbox validation (9 cases), migrated callers (21 cases), and the original ordered 78-file cohort (373 cases, no unhandled errors), plus a regression that failed against the old helper. It explicitly says the historical socket failure did not reproduce on baseline and does not present that replay as causal proof. Evidence is linked to https://github.com/openclaw/openclaw/actions/runs/35838998797 and https://github.com/openclaw/openclaw/actions/runs/35849809144. GitHub confirms the first run was cancelled, consistent with the disclosed lease cleanup; this review could not inspect its raw logs because their storage host was blocked.

Likely related people:

  • steipete: 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.

@steipete
steipete merged commit a78f122 into main Sep 23, 2026
159 checks passed
@steipete
steipete deleted the codex/deflake-browser-routes-round8 branch September 23, 2026 12:06
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

app: web-ui App: web-ui P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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