Repository navigation
fix(gateway): own standalone MCP App request lifetimes - #119388
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 28, 2026, 2:02 AM ET / 06:02 UTC. ClawSweeper reviewWhat this changesThis PR gives standalone MCP App browser requests their own HTTP lifetime, propagates cancellation into managed MCP calls without stopping shared catalog refreshes, and expands lifecycle and conformance coverage. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked until stronger real behavior proof is added - 4 items remain Keep open: the patch has one introduced, repairable policy defect and lacks verified exact-head real-behavior proof; no merged replacement was established. Priority: P1 Review scores
Verification
How this fits togetherStandalone MCP Apps run inside a browser shell served by Gateway. The shell validates a ticketed view, invokes session MCP tools and resources through Gateway, and returns results or cancellation to the App. flowchart LR
A[Standalone App window] --> B[Gateway HTTP request]
B --> C[Ticket and view validation]
C --> D[MCP App operation]
D --> E[Session MCP runtime]
E --> F[MCP server]
F --> G[Result or cancellation]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +1076, Tests +741, Docs +5, Other -1. Total +1821 across 19 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Remove the release-owned changelog entry and publish redacted exact-head Gateway-plus-Chromium conformance output that demonstrates the intended request lifecycle. Do we have a high-confidence way to reproduce the issue? Yes in source: a catalog refresh followed by a valid tool request previously used one complete-operation deadline; this review did not execute the failing flow. Is this the best way to solve the issue? Yes for the runtime path: retain session-owned per-RPC budgets while making the browser HTTP caller own cancellation; the changelog entry must be removed before merge. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 23a681efa6fc. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Fix for ClawSweeper P2 finding + proofFinding addressed: "Keep the deadline active through JSON body consumption"Root cause: The initial Fix: Refactored to a callback-based const withFetchDeadline = async <T>(
input: string,
init: RequestInit,
consume: (response: Response) => Promise<T>,
): Promise<T> => {
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), MCP_APP_FETCH_TIMEOUT_MS);
try {
const response = await fetch(input, { ...init, signal: controller.signal });
return await consume(response);
} finally {
clearTimeout(timer);
}
};The Regression test proofAdded two tests to
Test outputHead SHA: @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review P2 finding fixed: |
|
@clawsweeper re-review P1 fixed: Derive operation deadlines from the MCP server budget
P2 fixed: Execute the generated standalone shell in the deadline test
Acceptance criteria verified:
Head SHA: |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
P1 fix: persist operation timeout on the view lease + real browser proofFinding addressed: "Persist the operation timeout with the view (P1)"Root cause: Fix: Capture the owning server's The snapshotted value is config-derived and stable for the session lifetime — it matches the budget Files changed:
Regression tests
Real browser-to-Gateway proofServed the actual serialized Stalled-response trace (timeout fires):
Recovery trace (successful operation, timer cleared):
Test outputStatic checks: Head SHA: @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Addressing the [P1] Cover catalog refresh in the operation deadline finding — pushed in commit d5dc1ac. Root causeThe P1 finding is correct: a single browser operation request can span two server-side phases that each consume up to
So the worst-case server-side work for one browser request is FixDouble the operation deadline so the browser request covers the full server-side lifecycle: const OPERATION_TIMEOUT_PHASES = 2;
const operationDeadlineMs =
OPERATION_TIMEOUT_PHASES * (payload?.operationTimeoutMs ?? DEFAULT_OPERATION_TIMEOUT_MS) +
OPERATION_TIMEOUT_GRACE_MS;The initial view load keeps its fixed 30s budget (it only fetches view metadata, not tool results). The previous VerificationRegression test
The test fails on the pre-fix formula (aborts at 95s) and passes on the doubled formula (aborts at 185s), confirming it locks in the lifecycle coverage. Static checks: This also resolves the Resolve merge risk (P2) item, since the merge-risk scenario (browser aborting a still-valid server-side operation) is the same lifecycle gap. |
d5dc1ac to
624aae3
Compare
624aae3 to
e2ee974
Compare
Keep initial loading and individual MCP requests bounded without applying a derived single-request timeout to composed App operations. Carry caller cancellation through the HTTP request owner, isolate shared catalog waits, and preserve bounded graceful cleanup before terminal document teardown. Retire stale document/bootstrap responses and observe asynchronous catalog rejections without changing authorization, public SDK contracts, or retry behavior. Add serialized-owner regressions and real Chromium conformance. Rewrites openclaw#119388 while preserving the contributor's report and credit. Co-authored-by: 唐梓夷0668001293 <[email protected]>
e2ee974 to
cd87842
Compare
|
Merged via squash.
|
* fix(gateway): own standalone MCP App request lifetimes Keep initial loading and individual MCP requests bounded without applying a derived single-request timeout to composed App operations. Carry caller cancellation through the HTTP request owner, isolate shared catalog waits, and preserve bounded graceful cleanup before terminal document teardown. Retire stale document/bootstrap responses and observe asynchronous catalog rejections without changing authorization, public SDK contracts, or retry behavior. Add serialized-owner regressions and real Chromium conformance. Rewrites openclaw#119388 while preserving the contributor's report and credit. Co-authored-by: 唐梓夷0668001293 <[email protected]> * test(ui): preserve rendered MCP App diagnostics without suppression --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: 唐梓夷0668001293 <[email protected]>
What Problem This Solves
A standalone MCP App could report a timeout even when catalog discovery and tool execution each completed within the server's request budget. The browser applied one derived deadline to the combined operation, then invited a retry while the backend could still complete the original call.
The initial view-load hang was already fixed by #119276. This rewrite preserves that 30-second bound and fixes the remaining operation-lifetime defect. Thanks @tzy-17 for identifying the multi-stage problem. The signed commit retains
Co-authored-by: 唐梓夷0668001293 <[email protected]>.Blame traces the operation timer to #119276, authored by Peter Lee (@xialonglee) and merged by Dallin Romney (@RomneyDa) on August 10, 2026, in f502607. A later HEAD-metadata repair carried the same timer serialization forward. Stable-release inclusion has not been established.
Why This Change Was Made
The browser owns the App request lifetime; the managed runtime owns each upstream RPC budget. This removes the derived whole-operation timer and propagates actual cancellation through fetch, HTTP disconnect and the existing request context. Cancelling one catalog waiter does not cancel discovery shared with other callers. Typed request IDs and retirement-before-abort prevent late results from settling a replacement request.
One document-lifecycle owner handles active, graceful-teardown, suspended and closed states. App-requested teardown retains authorized cleanup RPCs until acknowledgment or the existing first one-second deadline. Terminal navigation closes work immediately. Persisted-document recovery reloads through canonical ticket validation without reviving a closed heap or replaying operations. Retired bootstrap and response-body completions cannot overwrite the live UI.
The asynchronous catalog-wait helper also keeps authorization-time cancellation inside
Promise.all's promise ownership, preventing synchronous argument evaluation from orphaning another rejection. No global rejection suppression is added.User Impact
Valid composed operations finish without an artificial browser timeout; graceful App shutdown can save state before unmounting. Cancellation stops this caller's wait and reaches managed requests, but cannot undo server side effects. History recovery starts a fresh App, resets transient state and does not retry interrupted work. Expired tickets require a fresh App link.
No new configuration, dependency, SDK field, protocol, persistent storage or authorization bypass is introduced. Initial loading remains bounded at 30 seconds; individual RPC deadlines and the public runtime timeout getter remain intact. The serialized host is executable browser code, not a persistent-state schema or migration.
Evidence
Before: real Chromium, the actual Gateway, official App SDK and a synthetic MCP stdio server reproduced the defect on the unmodified baseline. With a ten-second per-RPC budget, catalog listing took 8.009 seconds and tool execution 8.008 seconds, each once. The browser timed out after 15.117 seconds; the server wrote success 0.963 seconds later. Warm and shorter composed controls passed. Baseline run.
After: the complete candidate Chromium run passed 2/2 native tests, controller/wrapper exit 0. Catalog8s+call8s completed visibly in 16.069 seconds, with one listing and one successful tool call; warm8s and catalog8s+call1s controls completed in 8.146 and 9.052 seconds. Candidate run retained 63 integrity-checked artifacts. The linked lease workflow may appear cancelled following external cleanup; its actual native/controller/wrapper results were successful. This is distinct from required exact-head CI.
Both official App teardown callbacks completed exactly one cleanup-save RPC before the captured App frame detached. All five cancellation/recovery scenarios completed with fresh-call controls, including transport cancellation, no late browser settlement and an independent catalog waiter. Ordinary Back/Forward recorded fresh document time origins,
pageshow.persisted=false, no-store responses and one correlated successful fresh tool call. These are real Gateway/HTTP/stdio/official-App flows with a source-mounted Control UI component and synthetic data—not a full dashboard/model turn or installed-package test.Authentic owner regressions failed before repair; the final two-file Gateway suite passed 53/53. Coverage includes actual HTTP disconnect/partial-upload cases, serialized-host lifecycle, cleanup, typed IDs, shared catalog waits and retired bodies. The async-authorization regression uses the real handler with a synthetic close event, not a TCP disconnect; its corrected plain-async runtime reproduced the orphan without suppressing global rejection handlers. Canonical owning types, lint and guards passed.
Both fresh full-candidate reviews completed with no findings. Published head
cd8784239784d76ec743da300fc9f521330327f9contains the rebased repair and a separate diagnostic-helper fix. All six MCP production owners and browser assertions remain unchanged from the live-tested candidate. The helper uses Playwright's immediate rendered-text API instead of a lint suppression, without adding a wait or weakening an assertion; its text and metadata samples are not atomic.Fresh published-head proof: CI 33146017570 completed successfully. The dedicated real-Gateway MCP job ran the complete conformance file: 2/2 passed, bridge 12.324 seconds, composed-operation/cancellation 40.730 seconds, total 98.44 seconds. Its actual target and harness checkout was synthetic merge
cb522be4468c92b7683f708495103c318bef2920, combining this published head with main60dc0203cd35614c2273cede8d1c8193c3b1e75a; it was not a direct detached-head run. The fetched merge object has the expected parents and 18/19 candidate files byte-identical; the remaining assertion baseline exactly preserves the CI base plus this PR's original deletion. All runtime, test and diagnostic-helper bytes match. The PR check snapshot is 231 passed, 42 conditional skips, no failures or pending checks; the required CI gate and both dependency detector/guard checks passed. Native preparation passed without changing the published head. The normal pinned squash merge completed on August 28, 2026, at 06:33:50 UTC: a29e5c9a312f90a6d10643ded834a76b2dc4e863. The landed tree preserves all 18 non-baseline candidate files byte-for-byte; the assertion baseline is the complete landed parent baseline minus the original standalone entry. The entire landed tree was verified against that expected merge context, and Git's terminal-trailer parser confirms the original contributor credit exactly once.The previous CI run exposed three separate failures: the unrelated UI selector issue is fixed by #131541; this helper change fixes the suppression inventory failure (focused inventory: 4/4 passed); and the updater's hidden child-process failure was not reproduced by a subsequent complete 87-test Linux updater-file run. That 87-test result does not reproduce or waive the original full shard. The prior dependency detector's HTTP 500 is retained separately, not relabelled as candidate success.
Earlier candidate failures remain recorded: attempt 1 failed two fixture assertions; attempt 2 passed the bridge test but failed a history-navigation wait. Repairs bind observations to the actual frame, verify a new document when reopening, and use supported browser defaults for history. No product timeout, cache header, retry or assertion was relaxed.
Independent source-blind validation reports 6 passed, 0 failed, 1 blocked. Supplemental recorded frames resolve standalone model-denial/resource-body observations; only expiry-specific causal evidence remains blocked. Combined native and independent source-aware evidence was accepted for the changed repair and unchanged authorization boundary.
Playwright 1.62.1 does not support BFCache restoration and documents possible navigation timeouts/desynchronization when enabled. Ordinary history and serialized-owner page-event regressions are not live BFCache/Safari proof. See the Playwright navigation limitation.
The latest completed ClawSweeper review, reviewed at 06:02 UTC on this head, raised one changelog-policy P2. Disposition: retained under explicit maintainer direction. The user's instructions require a changelog entry for this user-facing fix and contributor credit, overriding the generic release-only policy; this is not a version release or artifact publication. The exact-head behavior/proof request and Rank-up move are addressed by the public full-file Gateway/Chromium job and successful full CI linked above. The optional additional detailed trace upload is skipped: no new raw traces or media are uploaded, and the existing before/after images retain their historical v7a identity. Direct SDK inspection, real managed transport execution and independent source reviews cover the runtime contract. The +92 production lines remain bounded to the six request/lifecycle owners while deleting the old timer, inline host and timeout projection. The detected 'serialized state' is executable browser closure/test fixture code, not persistent-store or schema change. Earlier lease-snapshot advice is superseded by removing the invalid composed timer; the historical raw-query artifact finding remains rejected, with its original exit1 preserved. No duplicate re-review was requested for this proof-only update.
Production +451/-359 (net +92); tests/support +2412/-687; guard tooling/baseline +2/-3; docs/changelog +5. Pure moves inflate raw churn. Retained production growth establishes request, document and graceful-cleanup ownership while removing the old timer, handler-wrapper path and private timeout projection.
Scoped follow-ups: Control UI remote WebSocket cancellation, native adapters without ambient request cancellation, upstream SDK numeric-zero cancellation, and remove-first dashboard integration. The fixture exercises public teardown before DOM removal. A separate hook follow-up is recorded: a retained
REBASE_HEADcan select the pre-commit sequencer shortcut after a completed rebase; this exact helper passed an explicit formatter check. This PR is merged; no post-squash runtime run is claimed beyond the exact-head CI and source-parity evidence above.