fix: prevent stack overflow in codebase indexing for large projects #7712
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.
Description
This PR fixes issue #7588 where codebase indexing fails with "Maximum call stack size exceeded" error when scanning large projects with 200k+ files.
Problem
When indexing large codebases, the recursive directory scanning in
listFilteredDirectoriesfunction would cause stack overflow due to unbounded recursion depth.Solution
limitparameter tolistFilteredDirectoriesto control the maximum number of directories scannedChanges
src/services/glob/list-files.ts:limitparameter tolistFilteredDirectoriesfunctiondirCounttracking and early termination logiclistFilesto pass remaining limit to directory scanningsrc/services/glob/__tests__/list-files-limit.spec.ts:Testing
All tests pass ✅
Fixes #7588
Important
Fixes stack overflow in
listFilteredDirectoriesby adding a limit parameter and tests for large project indexing.listFilteredDirectoriesby adding alimitparameter to control directory scanning depth.listFilesto pass remaining limit to directory scanning.list-files-limit.spec.tswith tests for stack overflow prevention, early termination, and limit distribution.list-files.tsto trackdirCountand handle limits inlistFilteredDirectories.This description was created by
for 8b8ef00. You can customize this summary. It will automatically update as commits are pushed.