Skip to content

fix(sync): avoid argument-stack overflow when gathering unresolved refs#1184

Open
ianmage wants to merge 1 commit into
colbymchenry:mainfrom
ianmage:fix/sync-stack-overflow
Open

fix(sync): avoid argument-stack overflow when gathering unresolved refs#1184
ianmage wants to merge 1 commit into
colbymchenry:mainfrom
ianmage:fix/sync-stack-overflow

Conversation

@ianmage

@ianmage ianmage commented Jul 6, 2026

Copy link
Copy Markdown

Summary

  • codegraph sync no longer aborts with Maximum call stack size exceeded on large projects (fresh index, big Perforce/git changelist, or the first sync after switching branches).
  • getUnresolvedReferencesByFiles chunked the file-path IN-list under SQLite's parameter limit, but then spread each chunk's matched rows into a single rows.push(...chunkRows). One chunk can match hundreds of thousands of unresolved_refs rows — enough to blow V8's argument-stack limit. Chunking bounds the SQL params, not the returned row count, so rows are now appended in a loop instead of spread.
  • Adds a regression test (getUnresolvedReferencesByFiles (large result set)) that inserts 130k refs sharing one file_path and asserts no throw.
  • Adds a ### Fixes entry under [Unreleased] in CHANGELOG.md.

Test plan

  • npm run build passes (tsc + copy-assets).
  • npx vitest run __tests__/db-perf.test.ts — new regression test passes.
  • npm test — full suite green (no regressions in chunking/ref tests).

getUnresolvedReferencesByFiles chunked the file-path IN-list under
SQLite's parameter limit, but then spread each chunk's matched rows
into rows.push(...chunkRows). On a large sync (fresh index, big
Perforce/git changelist, first sync after switching branches) one
chunk can match hundreds of thousands of unresolved_refs rows,
blowing V8's argument-stack limit with "Maximum call stack size
exceeded" and aborting the whole sync before it finishes.

Chunking bounds the SQL params, not the returned row count, so append
rows in a loop instead of spreading. Adds a regression test that
inserts 130k refs sharing one file_path and asserts no throw.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant