Skip to content

fix(browser): bound screenshot hangs and recover CDP session - #1591

Merged
vastsa merged 7 commits into
vastsa:mainfrom
ZxlDragonDoctor:fix/browser-screenshot-timeout-1510
Oct 12, 2026
Merged

vastsa merged 7 commits into
vastsa:mainfrom
ZxlDragonDoctor:fix/browser-screenshot-timeout-1510

Conversation

@ZxlDragonDoctor

Copy link
Copy Markdown
Contributor

Problem

Issue #1510 reports browser screenshots hanging until the outer plugin-tool budget expires. The issue logs show repeated screenshot calls each waiting about 110 seconds; the capture queue has no per-capture deadline, and the stalled CDP session can remain attached.

Solution

Bound both the bundled screenshot API and raw Page.captureScreenshot CDP calls to 30 seconds. On timeout, return TIMEOUT, detach the stalled BrowserCdp session, and release the per-page capture queue so the next call can reattach and proceed. Other CDP methods are unchanged.

Testing

  • node --test apps/desktop/test/browser-capture-resize.test.mjs — 12 tests passed.
  • pnpm --filter @pi-desktop/desktop typecheck — passed.
  • pnpm --filter @pi-desktop/desktop lint — passed.
  • node docs/scripts/check-docs.mjs — passed (570 pages; existing ADR-format notes remain).
  • git diff --check — passed.
  • Native Electron capture/resize E2E could not start because the Electron binary is unavailable in this checkout. The broad desktop suite was not green on this Windows host (287 failures and 1 cancellation; output includes missing WSL /bin/bash errors), so those failures are not claimed as passing.

Issue alignment

Refs #1510. This follows the maintainer's suggested per-capture 15–30 second timeout and queue recovery; detaching the CDP session on timeout ensures a stuck command does not retain the page's debugging session.

ZxlDragonDoctor and others added 7 commits October 12, 2026 18:50
Tested: node --test apps/desktop/test/browser-capture-resize.test.mjs
# Subtest: capture completion after native guest destruction preserves the original capture result
ok 12 - capture completion after native guest destruction preserves the original capture result
  ---
  duration_ms: 0.3673
  type: 'test'
Keep the translated E2E scenario and plugin API aligned with the English contract so both locales describe the same 30-second timeout behavior.
The main branch advanced during review. Preserve the contributor's commit and bring the request candidate up to date before rerunning validation.
The dedicated Electron capture/resize scenario was not part of the CI suite, leaving native window transitions unverified. Run it in the existing Xvfb job that installs Electron so the timeout recovery path is checked in a supported display environment.
Xvfb provides an X server but no window manager, so native full-screen state changes never completed in the new capture/resize scenario. Start Openbox for that step so the regression test exercises the desktop window transitions it asserts.
@vastsa
vastsa merged commit 0744809 into vastsa:main Oct 12, 2026
5 checks passed
vastsa pushed a commit that referenced this pull request Oct 13, 2026
#1591 gave screenshots a 30s deadline, but snapshot, click, fill,
evaluate and every other allow-listed cdpCommand still had none — a page
holding a native dialog open or running a busy loop hangs those tool
calls forever, the same failure class as #1510 (#1611).

The screenshot deadline becomes a generic withCdpDeadline over any CDP
round trip on the guest, wired into all five call sites with per-call
labels; the timeout recovery (detaching the debugger session) and the
TIMEOUT error code are unchanged, and calls that finish in time clear
their timer with no side effects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants