fix(stdio): bound embedQuery and fast-fail during background reindex#165
Conversation
The "Index is being updated in the background..." message was duplicated verbatim in four places. Extract to a single staleIndexWarning constant so future wording changes are a one-line edit. No behavior change. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Initial indexing of large repos (e.g. the cloud monorepo) can run for 10+ minutes, easily spanning more than 10 tool calls. The old advice "Use standard tools for the next 10 tool calls" was therefore wildly under-counted and confusing. Replace with a concrete fallback hint (grep/glob/find) and a more accurate duration. The "Index is being updated in the background" prefix is preserved so existing callers and tests that match on it continue to work. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…epth The underlying embedder HTTP client has a 10-minute timeout; without an outer bound, any embedder pathology (cold-start GPU, network drop, server crash mid-request) surfaces as a hang in Claude Code. Mirror the existing defaultSearchTimeout on idx.Search by wrapping embedQuery in a 20s context. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… results Replace the unconditional warning-only short-circuit with a deadline-aware embed attempt: - StaleWarning set: bound embed at defaultStaleEmbedTimeout (3s). On success, return stale-but-real results from the existing DB plus the warning; on ctx timeout/cancel, fall back to warning-only. - StaleWarning empty: defense-in-depth bound at defaultEmbedTimeout (20s). This is strictly better UX than warning-only when the embedding backend isn't actually saturated, while still avoiding the 10-minute hang when it is. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Hardens the
fix-hangingshort-circuit (merged in PR #161-ish) with three follow-ups uncovered during review:embedQuery(defense-in-depth) — Mirror the existingdefaultSearchTimeoutonidx.Search. Without an outer bound, the embedder's 10-minute HTTP client timeout surfaces as an effective hang in Claude Code on any embedder pathology (cold-start GPU, network drop, server crash mid-request). NewdefaultEmbedTimeout = 20s.StaleWarningwas set, throwing away results from the (still-readable) DB. Now we give the embed a short window (defaultStaleEmbedTimeout = 3s); if it succeeds, return stale-but-real results plus the warning; if it times out, fall back to warning-only.cloudwhere a first-time index runs 10+ minutes. New wording points atgrep/glob/findand notes that big repos take longer. Also consolidated four duplicate copies into a singlestaleIndexWarningconstant.Test plan
TestHandleSemanticSearch_EmbedQueryBounded— defense-in-depth path: blocking embedder, no StaleWarning, returns withembed queryerror within ~500ms (not 10 minutes)TestHandleSemanticSearch_StaleWarningFastEmbedReturnsStaleResults— fast embed + flock held: returns stale results from the DB plus the warningTestHandleSemanticSearch_StaleWarningShortCircuits— updated for new fast-fail behavior (embed is attempted, gets cancelled withinstaleEmbedTimeout)TestStaleIndexWarning_NoBrittleToolCallCount— asserts the new wordinggo test ./...PASS (~2 min)golangci-lint run ./...zero issuesgo vet ./...cleancloudrepo reproduction:lumen purge ~/workspace/go/cloud && lumen index ~/workspace/go/cloud(background), then semantic_search via stdio while indexer holds the flock — debug.log showsstale embed fast-fail: returning warning-onlywithtimeout=3sand the call returns immediately. No 10-minute hang.🤖 Generated with Claude Code