Repository navigation
fix(browser): name web-bundle budgets and recover web deadlines - #6036
Conversation
Name the existing heap, per-script, and total web-bundle phases, and reject a per-script deadline above the total. Promote capture, CDP command, source-map decode, and source-map fetch deadlines at today's defaults. Name DevTools timeoutMs, and state that discovery, cleanup grace, byte budgets, and Electron hook retention have no runtime override. Refs #5910 Co-authored-by: morluto <morluto@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f5c93aacb
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
[Medium impact] The reviewed changes appear safe to merge. SummaryThis PR names browser and web-analysis deadlines, exposes selected deadline settings, and keeps cleanup on separate fixed limits. The latest changes:
No new actionable issues or security issues were found in the changes since the previous review. Tests were inspected, not run. Whether another PR supersedes this one could not be checked because GitHub access was unavailable. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Next script] --> B[Check fixed result allowance and host heap room]
B --> C{Both have room?}
C -->|Yes| D[Start worker and read source]
C -->|No| E{Fixed allowance exhausted?}
E -->|Yes| F[Report fixed result budget]
E -->|No| G[Report host heap pressure]
F --> H[Stop further scripts and preserve completed facts]
G --> H
Reviews (9) · Last reviewed commit: "fix(browser): name the operand that stop..." · Reviewed by Greptile |
…dlines-2486 Co-authored-by: morluto <morluto@users.noreply.github.com>
Keep HTTP and browser-socket discovery on the fixed discovery deadline so a short command_timeout_ms starts at the handshake. Apply scenario command_timeout_ms to launch startup and the primary connect session, and keep service-worker restoration on the fixed 5000 ms grace. Omit command_timeout_ms from recovery text when the operation does not accept it. Co-authored-by: morluto <morluto@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c583cf8bff
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A timed-out scenario command stays owned so cleanup can close a late browser or context and restore a mutation that lands after the deadline. Child storage replies use that deadline, scenario recovery names command_timeout_ms in the capture JSON, and the session test connection implements beginCleanupGrace. Co-authored-by: morluto <morluto@users.noreply.github.com>
A nested command such as Page.enable that is delivered but never answered was stored as protocol_error, hiding the command name, selected deadline, and recovery. Store the typed timeout and assert that public error. Co-authored-by: morluto <morluto@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2bc278bd0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…dlines-2486 # Conflicts: # src/cli/electronCommands.ts Co-authored-by: morluto <morluto@users.noreply.github.com>
Switch runtime restoration to the cleanup grace before the first send so a short command_timeout_ms cannot fail an otherwise successful observation. Stop advertising command_timeout_ms on list_browser_targets, which never bounds a post-discovery command. Co-authored-by: morluto <morluto@users.noreply.github.com>
…anup Drive restoration through the runtime fixture. A cleanup command that outlives command_timeout_ms still succeeds, and a stalled restoration names the fixed 5000 ms grace. Co-authored-by: morluto <morluto@users.noreply.github.com>
codecBudgetLimitation reported a fixed 20-second deadline after a caller selected decode_timeout_ms. Result and Evidence limitations now name that effective millisecond deadline. Co-authored-by: morluto <morluto@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d5a3fdd28
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
A browser-level Target.attachToTarget no longer shares the WebSocket handshake budget. Blocked service-worker attachment keeps discovery on its fixed deadline and applies command_timeout_ms to the later handshake and attach. Co-authored-by: morluto <morluto@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97135d5b16
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Bun ignores the V8 old-space flag. A Windows Job reports the process commit limit, and other Bun hosts no longer suggest raising max_heap_mb. Co-authored-by: morluto <morluto@users.noreply.github.com>
WebSocket discovery enforces the 64 MiB protocol budget. Timeout recovery no longer advertises the 8 MiB HTTP document budget. Co-authored-by: morluto <morluto@users.noreply.github.com>
The first registration check has its own fixed 10s deadline. Discovery, handshake, and Target.attachToTarget stay on their separate deadlines. Co-authored-by: morluto <morluto@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48aa28e2d9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Host heap pressure no longer claims the fixed result budget is exhausted. A Windows Bun allocation before the commit limit still names that limit. Co-authored-by: morluto <morluto@users.noreply.github.com>
Summary
Refs #5910 (parent #5808). Web-bundle heap, per-script, and total deadlines already existed and now name those phases. Capture, CDP command, source-map decode, and source-map fetch deadlines become validated settings at today's defaults. DevTools startup already accepted
timeoutMsand now names it. Fixed discovery, cleanup grace, byte budgets, and Electron hook retention say there is no runtime override when the agent sees them.Review follow-up: a short
command_timeout_msstarts at the WebSocket handshake, after HTTP discovery. Browser-socket discovery keeps its own deadline. Scenario launch startup, connect-over-CDP, target lookup, environment commands, and storage CDP commands, including attached child replies, use the selected command deadline. A command that exceeds that deadline stays owned: cleanup closes a browser or context that appears afterward, and restores an environment mutation that completes afterward. Service-worker restoration stays on the fixed 5000 ms grace. Operations that do not acceptcommand_timeout_msdo not name that setting.capture-browser-scenariorecovery tells the caller to setcommand_timeout_msin the scenario JSON; that command has no--command-timeout-msoption. When Chrome acknowledges delivery of a child command such asPage.enableand never replies, the stored failure is that timeout. The public error names the command, the selected deadline, and the scenario JSON recovery.Runtime restoration calls
beginCleanupGracewith the fixed 5000 ms grace before the first restoration command, so a shortercommand_timeout_mscannot returncleanup_failedfor an otherwise successful observation.list_browser_targetsno longer acceptscommand_timeout_ms. HTTP discovery and browser-socket discovery stay on the fixed 10-second deadline, and the socket closes without a later command. That listing deadline has no runtime override.trace_web_source_locationlimitations name the effectivedecode_timeout_msin both the result and Evidence: the selected value, or 20000 ms when omitted. An omitted deadline stays absent from parameters.A browser-level
Target.attachToTargetreceives its owncommand_timeout_msafter the WebSocket handshake. Blocked service-worker attachment keeps the fixed discovery deadline on endpoint discovery; the following handshake andTarget.attachToTargeteach usecommand_timeout_ms.The first blocked service-worker registration check, before discovery, has its own fixed 10000 ms deadline.
command_timeout_msdoes not apply to that check. Discovery, the handshake, andTarget.attachToTargetstay on their separate deadlines.Web-bundle memory exhaustion names the resource the runtime enforces. Node names the selected V8 old-space heap. Windows Bun names the process commit limit (
max_heap_mbplus a 512 MiB reserve). Other Bun hosts say that raisingmax_heap_mbdoes not change the exit.Browser-socket discovery timeout recovery names the 64 MiB protocol message budget. HTTP discovery timeout recovery still names the 8 MiB document budget.
When web-bundle result admission reaches zero, the failure names the operand that did it. Host heap pressure, while the fixed 8 MiB result budget still has room, names that host headroom and does not say the fixed allowance has no further room. Exhaustion of the 8 MiB allowance still names that fixed budget. A Windows Bun allocation before the process commit limit is reported as reached still names the configured limit and says it was not reached.
Merged
origin/main(2aadcf7d0). The only conflict wassrc/cli/electronCommands.ts: the selected Electron page command timeout stays, and input failures keep main's issue diagnostics.Problem and expected behavior
Timeout and budget failures read as unnamed hard caps, or named a generic server deadline. A caller could not tell a per-script web-bundle timeout from the total analysis deadline, or raise the capture, CDP command, source-map decode, or source-map fetch deadline without a code change.
analyze_web_bundlenamesmax_heap_mb(default 1024 MiB, range 128..16384),analysis_timeout_ms(default 30000), andtotal_analysis_timeout_ms(default 300000). A per-script deadline above the effective total is rejected. Omitted values stay at today's defaults and stay absent from Evidence. On Bun,max_heap_mbis not a V8 old-space heap: Windows enforces a process commit limit plus a 512 MiB reserve, and other Bun hosts enforce no analyzer heap limit.These settings are adjustable, default unchanged, integer range 1..2147483647:
capture_timeout_ms/--capture-timeout-ms— 30000command_timeout_ms/--command-timeout-ms— 20000decode_timeout_ms/--decode-timeout-ms— 20000source_map_fetch_timeout_ms/--source-map-fetch-timeout-ms— 30000DevToolsActivePort startup still accepts caller
timeoutMs(default 60000) and the failure names that argument. HTTP CDP discovery is 10000 ms and 8 MiB. Browser-socket discovery is the same 10000 ms deadline and the 64 MiB protocol message budget. Cleanup grace (5000 ms), other protocol and capture byte budgets, source-map map/reply/codec-heap budgets, and the 16 MiB Electron hook retention stay fixed and say there is no runtime override. The blocked service-worker registration check before discovery is a fixed 10000 ms deadline with no runtime override.Omitted scenario
command_timeout_msmeans 20000. That value bounds launch startup. Actiontimeout_ms,wait_for_timeout.duration_ms, and navigation stay separate. It does not bound the pre-discovery service-worker registration check.list-browser-targetshas no--command-timeout-msoption. Passingcommand_timeout_mstolist_browser_targetsis rejected.Change and scope
Recovery text lives with the owning deadline. CDP connections, runtime sessions, the capture decoder, and the source-map codec use the selected value. Schema descriptions are the CLI and MCP contract; this does not regenerate the MCP catalog.
Follow the contribution scope. Not applicable: no new provider, target execution, injection, mutation, or protection recovery.
Intentionally not included: MCP catalog work (#6005), provider limits (#6014), JavaScript analysis heap (#6022), Android/JADX/apktool (#6024), and E2E scripts.
Contract and boundary impact
capture-browser-scenariotakes scenario JSON only.list_browser_targetsdoes not acceptcommand_timeout_ms.command_timeout_ms(20000 when omitted) where it previously waited without that deadline.command_timeout_ms. Source-location limitations name the effective decode deadline in milliseconds. Web-bundle memory failures name the exhausted resource for the running runtime.command_timeout_ms. A timed-out scenario command remains owned until it settles, so a late browser, context, session, or applied environment mutation is closed or restored.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): none committed. Public browser, capture, source-location, scenario-contract, and web-runtime docs name the controls.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
src/domain/webDeadlineControls.test.tscovers rejection of a per-script deadline above the total, omitted defaults, the 1..2147483647 range, recovery text that omitscommand_timeout_mswhen the operation does not accept it, and runtime-specific web-bundle exhaustion text (Node V8 heap, Windows Bun process commit limit, other Bun allocation, and a configured Windows limit that was not reported as reached). It also checks that host result capacity 0 with the fixed 8388608-byte budget still available names host pressure, and that a zero fixed allowance still names that fixed budget. Behavior tests apply non-defaultcapture_timeout_ms,command_timeout_ms,decode_timeout_ms, andsource_map_fetch_timeout_ms, including explicit-versus-omitted Evidence parameters, cleanup, discovery staying outside a short command deadline, handshake versusPage.getFrameTreelabeling, the fixed 5000 ms cleanup grace, and scenario launch plus primary connect. This follow-up adds late launch close-before-profile-removal, late connect close without blocking the timeout, late environment restore, a stalled childPage.enablereply bounded bycommand_timeout_ms, and scenario recovery that does not mention--command-timeout-ms. The stalled child reply test asserts the public timeout:Page.enable, the selected 40 ms deadline, and the scenario JSON recovery. The session test connection implementsbeginCleanupGrace. Runtime cleanup withcommand_timeout_ms250 keeps a hungProfiler.disableon the 5000 ms grace and still succeeds after that command completes; a stall names the fixed grace and does not name the 250 ms command deadline.list_browser_targetsrejectscommand_timeout_msand leaves it out of Evidence.WebSourceLocationService.test.tschecks that a selected 250 msdecode_timeout_msis named as250 ms decode_timeout_ms deadlinein both the result and Evidence limitations, and that an omitted deadline names 20000 ms while staying absent from parameters.cdpTargetDeadlinesdelays the browser-socket handshake and still expects one fullcommand_timeout_mstimer forTarget.attachToTarget. The blocked service-worker test expects the 10000 ms discovery timer to be gone once attach is in flight, with onecommand_timeout_mstimer active. A stalledframe.evaluateduring the first blocked registration check fails on its own 10000 ms deadline before any discovery request and without armingcommand_timeout_ms. Browser-socket discovery timeout text names the 67108864-byte protocol budget; HTTP discovery timeout text still names the 8388608-byte document budget.WebBundleAnalysisWorker.test.tsprojects a heap-marker exit through the same runtime classifier.WebBundleAnalysisWorkerCapacity.test.tsrefuses a zero host heap before launch and expects the host message, not the fixed-budget sentence.PlaywrightScenarioSession.test.tsbecause the mock connection lackedbeginCleanupGrace. The child-timeout thread was source-derived:fail()stored every cause asprotocol_error, sosettle()hid the typed timeout. The source-location deadline text was source-derived:codecBudgetLimitation()hardcoded “20-second deadline” after the decoder already used the selected timeout. The attach threads were source-derived: oneruntimeDeadlinewrapped handshake and attach, andwithCdpDiscoveryDeadlinestill enclosed the service-worker handshake and attach. Later threads were source-derived: web-bundle exit text always named the V8 old-space heap, browser-socket discovery timeout named the HTTP document budget, and the first blocked registration check no longer had a deadline. The latest threads were source-derived: a zero host-heap term still said the fixed result budget had no further room, and a Windows Bun allocation before the Job limit said no process limit was enforced.command_timeout_msin the capture JSON. A stalled child storage command surfaces that timeout directly. Target listing no longer advertisescommand_timeout_ms. Source-location limitations name the effectivedecode_timeout_msin milliseconds. A stalled browser-level attach namesTarget.attachToTargetand the selected command deadline. Web-bundle memory failures name the exhausted resource for Node, Windows Bun, or other Bun. A Windows Bun allocation before the commit limit names that configured limit and says it was not reached. Browser-socket discovery timeouts name the 64 MiB protocol budget. A stalled pre-discovery service-worker check names its fixed 10000 ms deadline. Host result pressure names host heap headroom while the fixed result budget still has room.heap_size_limitto 0.For evidence-bearing changes:
Validation performed
npm run check:fast— passed (typecheck and lint) on the tree committed ase96ace766.npm run test:focused -- src/domain/webDeadlineControls.test.ts src/browser/WebBundleAnalysisWorkerCapacity.test.ts src/browser/WebBundleAnalysisWorker.test.ts— passed, 28 tests, before the capacity-test type narrowing. After that narrowing,npm run check:fastpassed again andnpm run test:focused -- src/domain/webDeadlineControls.test.ts src/browser/WebBundleAnalysisWorkerCapacity.test.tspassed, 7 tests. The worker suite was not repeated after the type narrowing because that edit was only in the capacity test.48aa28e2d,npm run check:fastpassed.npm run test:focused -- src/domain/webDeadlineControls.test.ts src/browser/CdpEndpoint.test.ts src/browser/WebBundleAnalysisWorker.test.ts src/browser/PlaywrightScenarioSession.test.ts tests/boundary/browser/cdpTargetDeadlines.test.tshad 93 passed and 1 failed; the Windows Bun assertion was corrected,webDeadlineControlswas rerun (5 passed), andCdpEndpointwas rerun (11 passed). The worker (21), scenario session (36), andcdpTargetDeadlines(22) results were from the run before that assertion-only edit.97135d5b1,npm run check:fastpassed.npm run test:focused -- tests/boundary/browser/cdpTargetDeadlines.test.ts src/browser/PlaywrightScenarioSession.test.tspassed, 57 tests.npm run test:focused -- tests/boundary/browser/cdpWebRuntime.test.ts tests/boundary/browser/cdpWebRuntimeTermination.test.ts tests/boundary/browser/cdpBrowserProvider.browserSocket.test.tspassed, 36 tests. Those three CDP suites were not repeated after this follow-up.3d5a3fdd2,npm run check:fastpassed andnpm run test:focused -- src/application/WebSourceLocationService.test.tspassed, 20 tests. That source-location run was not repeated after later commits.618ea8df1,npm run test:focused -- tests/boundary/browser/webDeadlineBehavior.test.ts src/domain/webDeadlineControls.test.tspassed with the then-currentcdpTargetDeadlinescount. That behavior file was not repeated after later commits.npm run test:focused -- src/browser/PlaywrightScenarioBrowser.test.ts src/browser/PlaywrightScenarioStorage.test.tspassed, 42 tests. That run was not repeated after the main merge.Compatibility, safety, and release
total_analysis_timeout_msbelow the effective per-script deadline (including the 30000 ms default) is now rejected. Raiseanalysis_timeout_msonly up to the total, or raise the total. Launch startup is now bounded bycommand_timeout_ms(20000 when omitted).list_browser_targetsrejectscommand_timeout_ms; that field was not on main. Source-location limitation text now states the effective deadline in milliseconds (20000 ms decode_timeout_ms deadlinewhen omitted) instead of a fixed “20-second deadline”. A browser-level attach can now use a fullcommand_timeout_msafter a handshake that already consumed part of that same number of milliseconds. Bun web-bundle exhaustion no longer tells the caller the V8 old-space heap was exhausted. Browser-socket discovery timeouts name 64 MiB instead of 8 MiB. A stalled blocked service-worker registration check now fails after 10000 ms instead of waiting without a deadline. Host result pressure no longer says the fixed result budget has no further room. A Windows Bun allocation before the commit limit names that limit.Author readiness
Human owner: @morluto
Before merge
type(scope): outcome.