claude-code - 💡(How to fix) Fix [BUG] .rgignore patterns block REPL startup for ~7s on large repos (synchronous glob matching) [1 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52904Fetched 2026-04-25 06:17:46
View on GitHub
Comments
0
Participants
1
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
labeled ×5renamed ×1subscribed ×1

Starting claude in a large repository freezes the REPL for ~7 seconds because .rgignore patterns are applied synchronously on the Node event loop, blocking keystroke rendering. .gitignore does not exhibit this because it is processed asynchronously.

Root Cause

Starting claude in a large repository freezes the REPL for ~7 seconds because .rgignore patterns are applied synchronously on the Node event loop, blocking keystroke rendering. .gitignore does not exhibit this because it is processed asynchronously.

Fix Action

Fix / Workaround

Workarounds attempted (none worked except removing .rgignore)

Code Example

15:16:13.567  [FileIndex] git ls-files (tracked) took 654ms
15:16:13.596  [FileIndex] loaded ignore patterns from /opt/Repos/myrepo/.rgignore
15:16:20.436  [FileIndex] applied ignore patterns: 351891 -> 298915 files
15:16:20.437  [FileIndex] git ls-files: 298915 tracked files in 7524ms
15:16:20.611  [FileIndex] cache refresh completed in 7698ms

---

mkdir -p /tmp/cc-rgignore-repro && cd /tmp/cc-rgignore-repro
git init -q

# ~350K tracked files
for d in $(seq 1 1000); do
  mkdir -p "dir$d"
  for f in $(seq 1 350); do : > "dir$d/file$f.txt"; done
done
git add -A && git commit -q -m initial

# 150 .rgignore patterns
for i in $(seq 1 150); do echo "**/*pattern${i}*"; done > .rgignore

claude --debug
RAW_BUFFERClick to expand / collapse

Summary

Starting claude in a large repository freezes the REPL for ~7 seconds because .rgignore patterns are applied synchronously on the Node event loop, blocking keystroke rendering. .gitignore does not exhibit this because it is processed asynchronously.

Environment

  • Claude Code: 2.1.119
  • Node: v22.18.0
  • OS: macOS 26.4.1 (also expected on Linux/Windows — work is CPU-bound on the main thread)
  • Repo scale: ~352K tracked files, ~150 .rgignore patterns

Debug log (truncated)

15:16:13.567  [FileIndex] git ls-files (tracked) took 654ms
15:16:13.596  [FileIndex] loaded ignore patterns from /opt/Repos/myrepo/.rgignore
15:16:20.436  [FileIndex] applied ignore patterns: 351891 -> 298915 files
15:16:20.437  [FileIndex] git ls-files: 298915 tracked files in 7524ms
15:16:20.611  [FileIndex] cache refresh completed in 7698ms

The 6.84-second gap between loaded ignore patterns and applied ignore patterns is the entire freeze. During this window the REPL does not echo keystrokes.

Hypothesis

FileIndex performs ~352K paths × ~150 patterns ≈ 53M synchronous glob comparisons on the main thread. .gitignore filtering does not block because it runs asynchronously / post-mount; .rgignore does.

Minimal synthetic repro

mkdir -p /tmp/cc-rgignore-repro && cd /tmp/cc-rgignore-repro
git init -q

# ~350K tracked files
for d in $(seq 1 1000); do
  mkdir -p "dir$d"
  for f in $(seq 1 350); do : > "dir$d/file$f.txt"; done
done
git add -A && git commit -q -m initial

# 150 .rgignore patterns
for i in $(seq 1 150); do echo "**/*pattern${i}*"; done > .rgignore

claude --debug

Expected: REPL responsive immediately. Actual: REPL freezes for several seconds; debug log shows a multi-second gap between loaded ignore patterns and applied ignore patterns.

Scaling either dimension (file count or pattern count) reproduces proportionally.

Workarounds attempted (none worked except removing .rgignore)

  • respectGitignore: false in settings.json — only affects .gitignore, not .rgignore
  • CLAUDE_CODE_DISABLE_ATTACHMENTS=1 — no effect
  • Custom fileSuggestion command — FileIndex still runs and still freezes
  • Renaming .rgignore — works, but loses the ignore semantics

Related (closed) issues

  • #22950 — @ file completion indexing is slow on optimal hardware (related FileIndex perf, but @ picker, not startup)
  • #1104 — Feature request for .claudecodeignore / disable git indexing (tangential — this report is specifically about .rgignore blocking, not the absence of an ignore mechanism)

Neither covers the specific .rgignore synchronous-blocking behavior on REPL startup.

extent analysis

TL;DR

The most likely fix is to process .rgignore patterns asynchronously to prevent blocking the Node event loop.

Guidance

  • Investigate modifying the FileIndex component to apply ignore patterns asynchronously, similar to how .gitignore is processed.
  • Consider optimizing the glob comparison algorithm to reduce the number of synchronous comparisons.
  • Review the claude startup process to identify potential areas for parallelization or asynchronous processing.
  • Evaluate the feasibility of introducing a timeout or a progress indicator to mitigate the freeze during REPL startup.

Example

No code snippet is provided as the issue does not imply a specific code change, but rather a architectural or design modification.

Notes

The provided debug log and synthetic repro suggest that the issue is related to the synchronous processing of .rgignore patterns. However, without access to the FileIndex component's implementation, it is difficult to provide a precise solution.

Recommendation

Apply a workaround by modifying the FileIndex component to process .rgignore patterns asynchronously, as this is likely to prevent the blocking behavior and improve REPL responsiveness. This approach is chosen because it directly addresses the identified root cause of the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] .rgignore patterns block REPL startup for ~7s on large repos (synchronous glob matching) [1 participants]