Skip to content

Conversation

@mikolalysenko
Copy link

@mikolalysenko mikolalysenko commented Jan 10, 2026

Summary

  • 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

Testing

  • Added unit tests for the new filter functionality
  • All glob-related tests pass (21 tests)

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.

  • Introduces rollup.base/dist/sea configs, Babel setup, and SEA bootstrap; adds transform/modify plugins and env inlining
  • Adds bin entrypoints bin/cli.js, bin/{npm,npx,pnpm,yarn}-cli.js and dist/external bundling pipeline; vendors and patches deps under external/ and patches/
  • Replaces old cli.js and lib/** with new src-driven build and outputs under dist/
  • Revamps package.json (new name socket, engines, scripts, exports, overrides, lint-staged) and adds extensive build/test scripts
  • Adds GitHub workflows for lint, test, e2e, provenance publish, auto PRs, and Claude automation
  • Adds linting/formatting/type configs (eslint.config.js, biome.json, oxlint), EditorConfig, pnpm config, Husky hooks, env files, and ignore files
  • Updates docs and metadata (README.md, CHANGELOG.md, CLAUDE.md, LICENSE)

Written by Cursor Bugbot for commit fe7d65d. Configure here.

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]>
Copy link

@cursor cursor bot left a 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

@jdalton jdalton changed the base branch from main to v1.x January 10, 2026 21:14
Signed-off-by: John-David Dalton <[email protected]>
Copy link
Contributor

@jdalton jdalton left a 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!

@jdalton jdalton merged commit 9bbb8e8 into v1.x Jan 10, 2026
7 checks passed
@jdalton jdalton deleted the fix/smo-522-heap-overflow branch January 10, 2026 21:29
Comment on lines +156 to +165
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)
})
Copy link
Contributor

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')
Suggested change
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

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@jdalton jdalton mentioned this pull request Jan 11, 2026
3 tasks
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.

3 participants