Skip to content

fix(web): merge wide script analysis results without call spreads - #10446

Closed
viniciusdsandrade wants to merge 2 commits into
morluto:mainfrom
viniciusdsandrade:fix/10445-web-bundle-merge-capacity
Closed

viniciusdsandrade wants to merge 2 commits into
morluto:mainfrom
viniciusdsandrade:fix/10445-web-bundle-merge-capacity

Conversation

@viniciusdsandrade

Copy link
Copy Markdown
Contributor

Summary

Closes #10445

mergeScriptResults in src/domain/webBundleAnalyzerResult.ts merged each analyzed script's edges, routes, endpoints, webmcp_declarations, and inferences into the shared accumulator using push(...items). When any single script result exceeded JavaScript's call-argument stack capacity (for example 130,000 items on a V8 main-thread stack or ~65k on Bun/JSC), buildCapturedWebBundleAnalysis threw RangeError: Maximum call stack size exceeded.

Problem and expected behavior

Smallest trigger: passing an analyzed WebBundleScriptAnalysis containing 130,000 items in observations.edges, observations.routes, observations.endpoints, observations.webmcp_declarations, or inferences to buildCapturedWebBundleAnalysis.

Violated invariant: merging valid per-script analysis outputs must not fail with a call-frame argument limit RangeError inside result aggregation.

Expected behavior: append all five collections iteratively through a small shared helper so buildCapturedWebBundleAnalysis preserves every item in order beyond engine call-argument limits (matching sibling fixes #10362 and #10386).

Change and scope

  • Added a local appendAll helper in src/domain/webBundleAnalyzerResult.ts and replaced the five .push(...) spread calls inside mergeScriptResults (lines 222-226 on base).
  • Added tests/boundary/browser/webBundleResultCapacity.test.ts in the forked boundary Vitest project (sharing the CLI/MCP main-thread stack) verifying buildCapturedWebBundleAnalysis preserves 130,000 items for each of edges, routes, endpoints, webmcp_declarations, and inferences.
  • Scope: focused bug fix in mergeScriptResults and forked boundary regression test; sibling worker protocol byte caps (JAVASCRIPT_STATIC_FACT_BYTES) are unchanged.

Contract and boundary impact

  • Semantic owner and earliest changed stage: mergeScriptResults in src/domain/webBundleAnalyzerResult.ts owns per-script result aggregation into WebBundleAnalysis; public inputs and schema outputs are unchanged.
  • Contribution scope fit and linked maintainer decision: not applicable (existing local result-aggregation bug fix).
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: prevents V8 and JavaScriptCore RangeError on wide analyzed script results across all supported Node.js/Bun platforms.
  • Evidence, artifact, provenance, or reconstruction contract: preserves exact observation and inference order and provenance fields without dropping or truncating items.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/browser/webBundleResultCapacity.test.ts (parameterized across edges, routes, endpoints, webmcp_declarations, and inferences at 130,000 items on a forked test stack).
  • Base reproduction or other evidence: source inspection on upstream/main (5815178a8) confirmed five accumulator.*.push(...) spread calls in mergeScriptResults; CI verification pending on this draft PR.
  • User-visible CLI/MCP output (if applicable): analyze_web_bundle / buildCapturedWebBundleAnalysis completes instead of throwing RangeError: Maximum call stack size exceeded on wide analyzed script results.
  • Remaining proof gaps: local tests were intentionally omitted; full Vitest/typecheck/lint/format verification runs in GitHub Actions CI.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • Source diff review on 5815178a8 - verified strict TypeScript types, noUncheckedIndexedAccess handling, switch exhaustiveness, and formatting alignment; waiting for GitHub Actions CI checks.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: CI forked boundary suite verifies buildCapturedWebBundleAnalysis on Node.js main-thread stacks; live Chromium end-to-end capture with 130k synthetic observations was not run locally.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; retains existing schema validation and worker byte budgets.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Replaces five call-spread appends with an item-by-item helper, avoiding JavaScript call-argument limits while keeping item order.

  • Web-bundle analysis keeps every finding from very wide scripts.

Reviews (2) · Last reviewed commit: "test(web): use valid script_key format i..." · Reviewed by Greptile

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thank you for this fix. It landed in #10539 with your authorship kept on the commit, so I'm closing this PR as superseded.

@N0zoM1z0 N0zoM1z0 closed this Nov 14, 2026
@morluto morluto added bug Something isn't working area: runtime Process capture and runtime observation labels Nov 22, 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 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] buildCapturedWebBundleAnalysis overflows call stack when merging wide script observation or inference lists

3 participants