Skip to content

Replace remaining array push spreads with loops to prevent stack overflow (#3989) - #4150

Closed
ElNeMeR70 wants to merge 1 commit into
garrytan:mainfrom
ElNeMeR70:fix/pregate-push-spread-stack-overflow-3989
Closed

ElNeMeR70 wants to merge 1 commit into
garrytan:mainfrom
ElNeMeR70:fix/pregate-push-spread-stack-overflow-3989

Conversation

@ElNeMeR70

@ElNeMeR70 ElNeMeR70 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Replaces the remaining array push argument spreads across test selection and dependency graph helpers with iteration loops so large input arrays cannot overflow the V8 call stack. This completes the stack-safety cleanup for large repository runs.

Details

  • lib/pregate/lane-selection.ts: Replace why.push(...prov) with a for (const p of prov) loop.
  • lib/pregate/lanes.ts: Replace .push(...) spreads on reverseDirEdges, existing, and uncoveredChanged with for loops.
  • lib/pregate/import-graph.ts: Replace .push(...walkDir(full)) and .push(...specs) recursive/spec spreads with for loops.
  • lib/pregate/regen.ts: Replace out.push(...walkTrackedFiles(root, rel)) recursive spread with a for loop.
  • lib/pregate/context.ts: Replace files.push(...untracked) spread with a for loop.
  • test/pregate-lanes.test.ts: Add regression test verifying large provenance and changed-file arrays (>150,000 items) do not throw RangeError: Maximum call stack size exceeded.

Fixes #3989

@trunk-io

trunk-io Bot commented Nov 8, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@ElNeMeR70
ElNeMeR70 force-pushed the fix/pregate-push-spread-stack-overflow-3989 branch from 41032a1 to 37e137e Compare November 8, 2026 03:01
@ElNeMeR70 ElNeMeR70 changed the title fix(pregate): replace remaining push(...x) spreads with loops (#3989) Replace remaining array push spreads with loops to prevent stack overflow (#3989) Nov 8, 2026
@capy-ai

capy-ai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for finishing the sweep from #3989. The overflow only happens once these arrays pass roughly 100,000 entries (your regression test uses 150,000), and we haven't seen a repository reach that in these pregate paths. Pregate changes are also paused until 2026-11-21. So I'm closing this as won't-fix for now; #3989 stays open as the record if a real repository ever hits the limit.

@capy-ai capy-ai Bot added the wontfix This will not be worked on label Nov 8, 2026
@capy-ai capy-ai Bot closed this Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deferred review finding: lib/pregate/lane-selection.ts:227 — Other push(...x) spreads on the same path (lane-selection.t

1 participant