-
Notifications
You must be signed in to change notification settings - Fork 35
[SMO-522] Fix heap overflow in large monorepo scans #1026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add streaming-based filtering to globWithGitIgnore to prevent heap overflow when scanning large monorepos with 100k+ files. Instead of accumulating all file paths and filtering afterwards, files are now filtered during streaming which dramatically reduces memory usage. Changes: - Add `filter` option to globWithGitIgnore for early filtering during streaming - Add createSupportedFilesFilter helper to create filter from supported files - Update getPackageFilesForScan to use streaming filter - Add comprehensive tests for the new filter functionality Fixes SMO-522 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment @cursor review or bugbot run to trigger another review on this PR
Signed-off-by: John-David Dalton <[email protected]>
jdalton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ha! Good find in the negated glob!
| it('should handle negated gitignore patterns', async () => { | ||
| const result = await globWithGitIgnore(['**/*'], { | ||
| cwd: testDir, | ||
| }) | ||
|
|
||
| const relativePaths = result.map(p => path.relative(testDir, p)) | ||
|
|
||
| // The ignored directory should be excluded. | ||
| expect(relativePaths.some(p => p.startsWith('ignored/'))).toBe(false) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test expectation contradicts the negated gitignore pattern. The .gitignore contains ignored/ !ignored/package.json which means the ignored/ directory is ignored BUT ignored/package.json should be un-ignored and included in results. However, the test expects NO files from ignored/ to be present (expect(relativePaths.some(p => p.startsWith('ignored/'))).toBe(false)). This test will fail because ignored/package.json should be included due to the negated pattern.
Fix: Change the expectation to verify that ignored/package.json IS included:
expect(relativePaths).toContain('ignored/package.json')| it('should handle negated gitignore patterns', async () => { | |
| const result = await globWithGitIgnore(['**/*'], { | |
| cwd: testDir, | |
| }) | |
| const relativePaths = result.map(p => path.relative(testDir, p)) | |
| // The ignored directory should be excluded. | |
| expect(relativePaths.some(p => p.startsWith('ignored/'))).toBe(false) | |
| }) | |
| it('should handle negated gitignore patterns', async () => { | |
| const result = await globWithGitIgnore(['**/*'], { | |
| cwd: testDir, | |
| }) | |
| const relativePaths = result.map(p => path.relative(testDir, p)) | |
| // The ignored directory should be excluded except for the negated file | |
| expect(relativePaths).toContain('ignored/package.json') | |
| }) | |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
Summary
globWithGitIgnoreto prevent heap overflow when scanning large monorepos with 100k+ filesChanges
filteroption toglobWithGitIgnorefor early filtering during streamingcreateSupportedFilesFilterhelper to create filter from supported filesgetPackageFilesForScanto use streaming filterTesting
Related Issue
Fixes SMO-522
🤖 Generated with Claude Code
Note
Massive project overhaul to a TypeScript + Rollup-based distribution with new tooling, packaging, and CI.
rollup.base/dist/seaconfigs, Babel setup, and SEA bootstrap; adds transform/modify plugins and env inliningbin/cli.js,bin/{npm,npx,pnpm,yarn}-cli.jsand dist/external bundling pipeline; vendors and patches deps underexternal/andpatches/cli.jsandlib/**with newsrc-driven build and outputs underdist/package.json(new namesocket, engines, scripts, exports, overrides, lint-staged) and adds extensive build/test scriptseslint.config.js,biome.json, oxlint), EditorConfig, pnpm config, Husky hooks, env files, and ignore filesREADME.md,CHANGELOG.md,CLAUDE.md,LICENSE)Written by Cursor Bugbot for commit fe7d65d. Configure here.