Skip to content

fix(web): drive the render over the DevTools protocol — the DOM at a cap, late content waited for - #375

Merged
SSFSKIM merged 1 commit into
mainfrom
web-render-driver
Oct 25, 2026
Merged

SSFSKIM merged 1 commit into
mainfrom
web-render-driver

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Board #130. The web plugin's renderer now drives headless Chromium over the DevTools protocol on --remote-debugging-pipe instead of --dump-dom. It returns the DOM at a cap instead of nothing, waits for content that arrives after the virtual-time budget, and says so when a render may be partial or stays thin. web → 0.2.1 (rebased onto #376 and #377; main is at 0.2.0).

Diagnosis

  • The terraform hang. Chromium's harness for --dump-dom (components/headless/command_handler/headless_command.js) races the load event against --timeout. If the load wins, it sets pauseIfNetworkFetchesPending and waits for virtualTimeBudgetExpired with no cap. registry.terraform.io keeps a LaunchDarkly event stream open from 1.6 s, so the page's clock never advances and nothing is printed. The NetLog of a run killed at 45 s shows the stream as its only unfinished request. --timeout cannot fix it: with the budget, --timeout=15000 and --timeout=3000 hang the same way; without the budget, the DOM is dumped at the load event, and the Requirements table was missing in one of two runs.
  • Late content, from the coordinator's code-level comparison. The budget runs ahead the moment nothing is pending, so it can end before:
    • the animation frame in which a framework draws the data it already has. With 12 spinning threads loading the CPU, the old clipper returned package.elm-lang.org's 12-word shell in 6 of 10 runs. A probe found the shell when the budget ran out and the whole page two frames later.
    • a worker's request, which does not pause the page's clock. A test page whose worker fetches its words is still the shell when the budget runs out, every time.
  • Not a render problem: crates.io's sidebar (license, SLoC, size) is in the rendered DOM. Defuddle drops it as not part of the article, so the page has 242 words either way. That belongs to extraction.

What behaves differently

  • How the page is loaded. The render waits as before (load, then the 10 s virtual-time budget). It then lets the page settle: the page's clock is stepped in 100 ms budgets at about real speed, and the DOM is taken once it has not changed for 500 ms, at most 5 s after the budget.
  • The cap. A page that has not settled 3 s before the 30 s limit is taken as it stands, with a note: the page was still loading after 27 s; this is how headless Chromium had rendered it by then.
  • A thin render says so: even rendered, the page holds only N words; its content may load later than the render waits, or come from an API the page calls.
  • The NetLog is read as soon as Chromium has closed it, within 20–100 ms of Browser.close. The headless shell often takes 10 s more to exit.
  • Unchanged: the proxy and egress flags, the fresh profile, and the NetLog evidence of the served document.
  • Cost: each render takes about 0.5–1.5 s longer (the settle). Terraform takes 29 s (the cap).

The Decision Log entry in the design lists the alternatives rejected: --timeout, a WebSocket driver on a port, Playwright, unsticking the clock through the proxy or the Fetch domain, network idle, and a second render.

Verification

  • cd web/clipper && npm test: 0 skipped (Chromium present), including the egress trap test at 0 TCP connections and 0 UDP packets.
  • New tests:
    • a page holding an event stream open: the DOM at the cap, with the note;
    • worker-fetched content written by a timer: waited for;
    • a thin render: the note;
    • against a stand-in browser (test/fixtures/fake-chrome.mjs), so they also run in CI: a reply and its event arriving in one read, a page that never spends its budget, a failed navigation, a browser that cannot start.
  • The real-Chromium tests fail on the old renderer. The one-read test fails if listening starts after the reply. The worker test fails without the settle.
  • Before and after, live, --refresh, words (seconds):
Page Before After
registry.terraform.io vpc 5.0.0 0, "rendering stopped after 30 s" (30.6) 7,001, Requirements table aws >= 5.0, "still loading" note (28.8)
deps.dev requests 2.31.0 471 (3.2) 471 (3.0)
artifacthub nginx 15.0.0 3,480 (2.9) 3,480 (3.7)
npmgraph express 4.18.2 317 (2.6) 317 (4.1)
crates.io serde 1.0.200 242 (1.9) 242 (3.8)
package.elm-lang.org list-extra 8.7.0 5,216 (2.5) 5,216 (3.4)
package.elm-lang.org list-extra latest 5,216 5,216 (5.1)
excalidraw.com 51 (2.3) 51 (2.9)
notion.notion.site 28 (14.0) 28, thin note (14.0)
vitejs.dev/guide (not rendered) 1,341 1,341

What the rebase changed

Residue (not in this PR)

  • crates.io's sidebar is dropped by extraction (Defuddle), not by the render. It needs its own ticket on the extraction side. web-clipper-fixes owns extract.ts.
  • A page that holds a stream open (terraform) now costs the full cap, 29 s. Failing event streams through the Fetch domain to unstick the clock was tried and rejected: its pattern paused ordinary requests too.

Sminos-Session: web-fetch-plugin#700c5e84 (doperpowers on macbook)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T20:33:31.224213Z 1188108 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…cap, late content waited for

Board #130. registry.terraform.io kept headless Chromium busy until the
30 s limit and nothing came back: Chromium's --dump-dom harness waits for
the virtual-time budget with no cap once the page has loaded, and the
page holds a LaunchDarkly event stream open, so its clock never moves.
--timeout caps only the load.

The clipper now drives the headless shell itself over
--remote-debugging-pipe (clipper/src/cdp.ts; no port, no new dependency):
the same load and 10 s virtual-time budget, then a settle in which the
page's clock is stepped at about real speed until the DOM has not changed
for 500 ms (at most 5 s), and the DOM taken as it stands 3 s inside the
limit when the page never settles, with a note. The settle catches what
the budget does not wait for: package.elm-lang.org drawn in an animation
frame after the budget (6 of 10 runs a 12-word shell under CPU load
before, 0 of 10 after), and a worker's request. A render that leaves the
page under 50 words now says so. The NetLog is read once Chromium has
closed it, since the process can take 10 s more to exit.

Proxy (its Boundary, deny list included), egress flags, fresh profile and
NetLog evidence are unchanged; the egress trap tests still show 0 TCP
connections and 0 UDP packets, and a rendered page requests nothing from
a denied host.
Decision Log entry and diagnosis in the design. web 0.2.1.

Sminos-Session: web-fetch-plugin#700c5e84 (doperpowers on macbook)
@SSFSKIM
SSFSKIM merged commit 780fd41 into main Oct 25, 2026
6 checks passed
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.

1 participant