Bound WordPress diagnostic setup/collect in capture-html (fix 25-min hang under contention)#1650
Merged
Merged
Conversation
wordpress.capture-html attaches the WordPress browser diagnostic provider,
whose setup runs an external playground command (browser-diagnostics-setup)
before navigation and whose collect runs in the finally block. Both were
awaited with no liveness bound, so a provider wedged under runtime contention
rode the recipe-level timeout — observed as capture-html hanging for the full
25-minute recipe budget while the sibling browser-probe navigation path failed
fast at its 120s wall bound (navigation itself is already bounded identically
for both commands).
Wrap the provider setup and collect calls in a bounded liveness helper
(runBoundedBrowserDiagnostic) using the same wall budget as navigation, so a
stuck or failing provider fails fast with a clear, non-empty error surfaced as
a non-fatal probe error instead of blocking the capture. Diagnostics remain
best-effort: a timeout or rejection degrades to "diagnostics unavailable"
rather than aborting the run.
Also thread the runtime abort signal into runHtmlCaptureCommand so the
orchestrator can interrupt capture-html the same way it can interrupt
browser-probe, which previously received no abort signal.
Blocked external requests under network-policy=block are already completed via
route.abort("blockedbyclient"), so they do not leave the page pending — no
change needed there.
Add deterministic coverage proving the bounded helper fails fast with a real,
non-empty error, preserves legitimately resolved (including falsy) values, and
surfaces underlying rejection reasons.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes
wordpress.capture-htmlhanging the full 25-min recipe timeout under contention — the blocker behind the live-WP parity cross-check (all 5 fixtures of an offloaded matrix run hung atsteps[3]: capture-html).Root cause (verified — not the obvious one)
Navigation is NOT the problem:
capture-htmlandbrowser-probeboth route throughrunSingleBrowserProbeCommand, andpage.gotois bounded identically (timeout: wallTimeoutMs+withBrowserProbeLiveness(..., "navigation"), 120s). The real issue is the WordPress diagnostic provider that only capture-html-style calls attach:browser-probe-runner.tsawait provider.setup(...)runs BEFORE navigation, unbounded.setup=installBrowserWordPressDiagnostics, which runs the externalwordpress.browser-diagnostics-setupPHP command. Under contention (~21 children / ~10GB RSS) that wedges → unbounded await → the whole command hangs and rides the 25-min recipe timeout. (browser-probefailed fast at 120s because navigation timed out; capture-html never reached navigation — it hung in setup.)await provider.collect(...)in thefinallyblock was likewise unbounded.runHtmlCapturedidn't passabortSignal(browser-probe did), so the orchestrator couldn't interrupt capture-html.route.abort("blockedbyclient")'d — they don't leave the page pending; no change needed there.)Fix
runBoundedBrowserDiagnostic: wraps each providersetup/collectinwithBrowserCommandLivenesswithdiagnosticsTimeoutMs(= the 120s nav wall). A stuck/failing provider now fails fast with a clear, non-empty liveness error surfaced as a non-fatal probe error; diagnostics degrade to best-effort instead of hanging. A discriminated result preserves legitimately-resolved falsy values (setupcan returnfalse).abortSignalthroughrunHtmlCaptureCommand+ passedthis.activeExecutionSignalfromplayground-runtime.runHtmlCapture, so capture-html is interruptible like browser-probe.networkidleagainst WP heartbeat fails fast at the wall rather than hanging — changing the default would alter the contract without fixing the actual hang).Verification
npm run build(tsc -b) clean.test:browser-diagnostic-providers,test:browser-runner-template,browser-probe-contract-smokegreen. Newtests/browser-capture-html-diagnostics-reliability.test.ts: hung op fails fast (<5s, names the phase), resolved-falsy preserved as ok, rejection surfaces the real message.Honest limit
Single-fixture live
capture-htmlconfirmation is PENDING — it boots a full Playground+Chromium sandbox (RAM-heavy; site rules require offloaded homeboy-lab, not set up in this scoped pass). Why it resolves deterministically: the only capture-html-specific unbounded paths (provider setup pre-nav, collect in finally) are now bounded by the same 120s wall as navigation → worst case ~setup+nav+collect (a few min), well under the 1,500,000ms recipe timeout; otherwise DOM returns viapage.content()normally with diagnostics degraded to best-effort. Unit test proves the bounding + real-error + value-preservation without a sandbox.AI assistance