fix(sync): avoid argument-stack overflow when gathering unresolved refs#1184
Open
ianmage wants to merge 1 commit into
Open
fix(sync): avoid argument-stack overflow when gathering unresolved refs#1184ianmage wants to merge 1 commit into
ianmage wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codegraph syncno longer aborts withMaximum call stack size exceededon large projects (fresh index, big Perforce/git changelist, or the first sync after switching branches).getUnresolvedReferencesByFileschunked the file-pathIN-list under SQLite's parameter limit, but then spread each chunk's matched rows into a singlerows.push(...chunkRows). One chunk can match hundreds of thousands ofunresolved_refsrows — 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.getUnresolvedReferencesByFiles (large result set)) that inserts 130k refs sharing onefile_pathand asserts no throw.### Fixesentry under[Unreleased]inCHANGELOG.md.Test plan
npm run buildpasses (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).