Skip to content

fix(browser): keep metadata-budget fixture scripts alive across captures - #3033

Closed
bercedev wants to merge 1 commit into
morluto:mainfrom
bercedev:fix/metadata-budget-fixture
Closed

bercedev wants to merge 1 commit into
morluto:mainfrom
bercedev:fix/metadata-budget-fixture

Conversation

@bercedev

Copy link
Copy Markdown
Contributor

Fixes #3006.

Problem

browser-capture-metadata-budget-e2e.mjs serves a page with five 2 MiB inline scripts and then runs four independent captures against it: CLI inspect, CLI bundle, MCP inspect, MCP bundle. Each script only did globalThis[marker] = true, so once it had run nothing referenced it. V8 is free to collect such a script, and a collected script is not replayed as scriptParsed to a later capture, since each capture opens its own Debugger session. The later MCP capture then saw no scripts and the fixture failed with scripts=0, retained_maps=0, excluded=undefined.

Change

Each script now leaves a function behind (globalThis[marker] = () => true), which keeps the script alive for the whole CLI/MCP sequence. The five full-size sourceMappingURL annotations, the 10 MiB of declared metadata, the admission budget and every assertion are unchanged. No production code is touched.

Verification

I could not reproduce the failure by just running the fixture on Linux (it passed 3 of 3), so I forced the condition the issue describes: a copy of the fixture that sends HeapProfiler.collectGarbage to the page right before the MCP phase. The shipped fixture file has no such call.

Chromium 155.0.8059.39 (Debian bookworm, headless, --no-sandbox), Node 24.21.0, in a container, after npm ci and npm run build:cached:

Fixture As shipped With GC forced before the MCP phase
main (boolean) 3/3 pass 3/3 fail, scripts=0, retained_maps=0, excluded=undefined
this PR (function) 3/3 pass 3/3 pass, scripts=5, retainedMaps=1, omittedMaps=4

The failure text is the one from the issue.

Checks run on the changed file: oxfmt --check clean, oxlint 0 errors (2 warnings, both there before this change).

Not run: npm run check, the full verify:browser composite, and anything on Windows or Edge, which is where the issue was observed. I drove verifyBrowserCaptureMetadataBudget directly with a small launcher instead of the composite.

The issue also asks to look at other fixtures for the same multi-capture lifetime assumption. I did not do that here; this PR is only the fixture named in the report.

Note: I used Claude Code while working on this. I ran the reproduction and the checks above myself.

The fixture's five inline scripts only assigned a boolean, so nothing
referenced them once they had run. V8 may collect such a script, and a
collected script is not replayed as scriptParsed to a later capture, each
of which opens its own Debugger session. The later MCP capture then saw
scripts=0.

Each script now leaves a function behind. Annotations, budget and
assertions are unchanged.

Fixes morluto#3006
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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 ⚠️ Failed 2026-10-13T23:11:51.968506Z 62774e1 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.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low impact] The fixture change appears safe to merge.

Summary

Keeps each fixture script alive by storing a function on globalThis instead of a boolean.

  • The metadata-budget fixture keeps its scripts alive across captures.

Reviews (1) · Last reviewed commit: "fix(browser): keep metadata-budget fixtu..." · Reviewed by Greptile

@morluto morluto added area: runtime Process capture and runtime observation bug Something isn't working labels Oct 13, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Own service-worker CDP registrations and retry failed teardown. Admit redaction and network metadata against remaining capture capacity, retain explicit omission reasons, and preserve source URL, redirect ancestry, caller-selected content, and historical capture values. Forward CLI cancellation through provider cleanup.

Reviewed fixes: #2263, #2637, #2767, #2845, #2859, #2863, #2872, #2874, #2876, #2879, #2955, #2957, #2961, #3033.

Validation: 25 current event/network source tests passed; earlier focused browser lanes passed 201 source tests and 176 boundary tests with two skips, plus 35 Python tests. Real browser/Windows lanes were not rerun. Playwright allocation before admission remains unbounded by these retention limits.
@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-fix track: this change is already on main. f690571 lists #3033 among its reviewed fixes and makes the identical fixture change: each script assigns ()=>true so V8 keeps it reachable across the later Debugger sessions. Only the comment wording differs. The PR's checks were green; it was flagged only for conflicting with main. I didn't push an empty merge. This PR looks safe to close as superseded.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@morluto

morluto commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Addressed on main in f690571; thank you @bercedev for the contribution.

The exact fixture change is on main: each large inline script leaves a function reachable so V8 cannot collect it before independent later debugger sessions. The PR's forced-GC reproduction showed baseline failure and patched fixture success (3/3), preserving budget/assertions.

Validation: Main verifier fixture: scripts/lib/browser-capture-metadata-budget-e2e.mjs; PR recorded 3/3 shipped runs and a forced HeapProfiler.collectGarbage reproduction (baseline failed 3/3, fixed fixture passed 3/3).

Remaining diff: This PR has a single fixture-file change and that exact behavior is already committed. No production code or separate dependency change remains.

Verification scope: PR's verification used Chromium 155 on Linux; the originally reported Windows/Edge scenario was not run. The PR itself states that the shipped fixture has no forced-GC call. Current whole-main CI qualification remains in progress.

@morluto morluto closed this Oct 14, 2026
@bercedev
bercedev deleted the fix/metadata-budget-fixture branch October 14, 2026 08:12
@morluto morluto added the area: tests Test suite and verification label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation area: tests Test suite and verification bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Browser metadata-budget verifier does not retain scripts across captures

3 participants