[PR #3033] [CLOSED] fix(browser): keep metadata-budget fixture scripts alive across captures #5570

Closed
opened 2026-10-31 01:07:39 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3033
Author: @bercedev
Created: 10/13/2026
Status: ❌ Closed

Base: main ← Head: fix/metadata-budget-fixture


📝 Commits (1)

  • 62774e1 fix(browser): keep metadata-budget fixture scripts alive across captures

📊 Changes

1 file changed (+4 additions, -1 deletions)

View changed files

📝 scripts/lib/browser-capture-metadata-budget-e2e.mjs (+4 -1)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/3033 **Author:** [@bercedev](https://github.com/bercedev) **Created:** 10/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/metadata-budget-fixture` --- ### 📝 Commits (1) - [`62774e1`](https://github.com/morluto/rea/commit/62774e1af791455f41ede15eca062b8b178261b9) fix(browser): keep metadata-budget fixture scripts alive across captures ### 📊 Changes **1 file changed** (+4 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `scripts/lib/browser-capture-metadata-budget-e2e.mjs` (+4 -1) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:07:39 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5570
No description provided.