Repository navigation
Description
Type
Bug
Problem / Value
If even one file fails to index, the code index switches to Standby ("Indexing stopped. Partial index data preserved.") and stays there until someone clicks Start Indexing or reloads the window. While it is in Standby, codebase_search rejects every query with Code index is not ready for search. Current state: Standby, so agents silently lose semantic search for hours. On 2026-11-02 this happened twice and blocked 33 searches across 19 tasks.
Four problems combine to cause and hide this:
- No retry. A single transient network error fails a file for good. PR [code-index] Isolate parsing so parser failures stop indexing safely #34 removed the batch retries the scanner used to have. This caused the morning outage.
- No recovery. One failed file latches the whole index in
Standby, failed files are never retried, and search refuses a partial index. - Racy Start Indexing. The manual fix runs two rebuilds at once and logs an unhandled
CodeIndexManager not initializederror that looks like the cause of the outage. - No logging. Failures and state changes aren't recorded anywhere installed builds keep them, so the evening trigger can't be identified.
Context
Environment: Roo Code 3.53.7 fork build (bin/roo-cline-3.53.7.vsix, includes PR #34), VS Code 1.144.0, Windows 11 Enterprise build 26300, OpenAI-compatible embedder (3072-dim), Qdrant v1.16.3 in local Docker. Source reviewed: fork main @ 9c78783.
Timeline (PST), reconstructed from task ui_messages.json, docker logs qdrant, and the VS Code logs:
| Time | Event |
|---|---|
| 06:12–09:12 | 7 codebase_search calls succeed |
| 08:55:11 | Extension host restart → full scan starts (Qdrant: GET collection, PUT /index) |
| 09:18:13 | [Extension Host] Failed to upsert points: TypeError: fetch failed (renderer.log), not retried (part 1) |
| 09:40:37 | Last scan write to Qdrant; scan ends partial → Standby |
| 10:10:53–11:57:05 | 28 searches fail in 17 tasks: Code index is not ready for search. Current state: Standby |
| 15:58 | VSIX reinstall + window reload → scan 15:58–16:03 completes without errors |
| 16:04–18:50 | 62 searches succeed |
| 18:54:33 | Last Qdrant write (file-watcher update after prettier --write); no Qdrant traffic at all until 19:02:03; trigger unknown (part 4) |
| 19:00:11–19:01:41 | 5 searches fail in 2 tasks, same error |
| 19:02:05 | Start Indexing clicked → services rebuilt → scan; unhandled error logged (part 3) |
| 19:22–19:42 | 14 searches succeed |
- verified: task histories contain 33
Error codebase_search: Code index is not ready for search. Current state: Standbymessages, all inside the two outage windows above. - verified:
docker logs qdrantshows 0 non-2xx responses and no warnings or errors for 08:55–10:12 and 18:45–19:03 PST. - verified: no embedder errors were logged. The OpenAI-compatible embedder
console.errors every error it throws (openai-compatible.ts#L352), and those are persisted in renderer.log.
Part 1 — No retry on transient write failures (regression from PR #34)
- Morning trigger, 09:18:13 (renderer.log):
[Extension Host] Failed to upsert points: TypeError: fetch failed. Qdrant logged nothing for it, so the request failed client-side at the connection level and never got a response. The scan finished at 09:40:37 as partial →Standby. - Upstream retried each embed + upsert batch: origin/main scanner.ts#L385-L463 loops
while (attempts < MAX_BATCH_RETRIES && !success)withINITIAL_RETRY_DELAY_MS * 2^(attempts - 1)backoff (3 attempts, 500 ms base). - verified:
git log -S MAX_BATCH_RETRIESpoints at a21bd59 ("fix(code-index): preserve progress and fence cancelled indexing attempts", part of PR [code-index] Isolate parsing so parser failures stop indexing safely #34) as the commit that removed it.git grepfinds no retry logic in forkfile-completion.ts,scanner.ts,file-watcher.ts, orqdrant-client.ts. - Fork write path, with no retry anywhere:
FileIndexWriter.replace→createEmbeddings→upsertPoints(logs at L386 and rethrows) → completion:deletePointsByFilePath+countPointsForFileverification (file-completion.ts#L79). Any throw fails the file. - Embedders still retry their own HTTP calls (for example 429 in
openai-compatible.ts), but the Qdrant upsert, delete, and count calls don't.
Part 2 — One failure latches the index in Standby
- File-watcher batches run
this.incompleteBatch ||= incomplete.incompleteBatchstartsfalse(L22) and is never reset, sohasIncompleteFiles()stays true and every later batch ends inStandbyat L96 — even when every later batch succeeds. - Failed files are not retried. A failed watcher file (file-watcher.ts#L244) is not re-queued; it is only retried if it changes again or on a full rescan. A failed scan file is collected in
batchErrors(orchestrator.ts#L141), setsincompleteScan(L158) and ends the scan inStandby(L164) with no retry pass. - Search refuses a nearly complete index: search-service.ts#L35-L38 only allows
IndexedorIndexing. - The only way out is manual: Start Indexing or a window reload recreates the orchestrator, which clears the latch. Nothing tells users or agents to do that, and the status text ("Indexing stopped. Partial index data preserved.") suggests someone stopped indexing on purpose (see [BUG] Make indexing stop status reflect what actually stopped #36).
Part 3 — Start Indexing runs two rebuilds at once
Clicking Start Indexing while the index is in Standby with live services (exactly the state part 2 leaves behind) starts two service rebuilds at the same time. Observed 2026-11-02 19:02:05 in %APPDATA%\Code\logs\<session>\window1\exthost\exthost.log. It is not in the Roo-Code output channel, because the handler never awaited the promise and its catch never saw the error:
2026-11-02 19:02:05.572 [error] Error: CodeIndexManager not initialized. Call initialize() first.
at t.assertInitialized (%USERPROFILE%\.vscode\extensions\rooveterinaryinc.roo-cline-3.53.7\dist\extension.js:2608:35242)
at t.startIndexing (%USERPROFILE%\.vscode\extensions\rooveterinaryinc.roo-cline-3.53.7\dist\extension.js:2608:37134)
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
Sequence:
- webviewMessageHandler.ts#L2422:
await manager.initialize(). Services are alive and not stopped (manager.ts#L225), so nothing is rebuilt. - L2424: the state is
Standby→ L2426:manager.startIndexing()is called withoutawaitor.catch. - manager.ts#L250-L262: state
Standby→await this._recreateServices()(attempt N). Before its firstawait, L384-L392 bumps the attempt counter, callsstopWatcher()(which setsservicesStopped = true, L290) and clears_orchestrator. - Back in the handler, L2428-L2429:
!manager.isInitializedis now true →await manager.initialize()→servicesStoppedis true →_recreateServices()runs again (attempt N+1). - Attempt N is now stale and returns early (L427-L429 or L441) without creating an orchestrator → L271
this.assertInitialized()throws → unhandled rejection. - Attempt N+1 finishes and
initialize()starts indexing (L232-L237). The secondstartIndexing()at L2430-L2431 is skipped only because the state is nowIndexing.
The same unawaited call appears at L2469 (toggleWorkspaceIndexing) and L2503 (setAutoEnableDefault). The doc comment at manager.ts#L247 ("should NEVER be awaited") encourages calls without .catch.
- verified: the stack frames match
assertInitialized←startIndexingresumed after anawait. Local uncommitted changes towebviewMessageHandler.tsdon't touch these handlers.
Part 4 — Failures and state changes aren't logged
- The Roo-Code output channel had zero indexing lines all day. Code-index services log through
console.*; installed builds keep onlyconsole.error(renderer.log, as[Extension Host] …) and unhandled rejections (exthost.log). - The evening trigger is unknown: the last Qdrant write was at 18:54:33, there was no Qdrant traffic at all until the manual restart at 19:02:03, and the first failed search was at 19:00:11. Embedder and Qdrant errors are ruled out because both would have been logged. The remaining candidates are all silent today:
- a file read failure (file deleted or locked mid-batch, for example by test or formatting tools) →
local_errorat file-watcher.ts#L244 - a count-verification mismatch → file-completion.ts#L79
- an oversized chunk skipped with only a
console.warn(openai-compatible.ts#L137), which then throwsIncomplete embeddingsat file-completion.ts#L115 - a non-fatal parser error or write-gate rejection inside the watcher's
processFile
- a file read failure (file deleted or locked mid-batch, for example by test or formatting tools) →
- Where failures are swallowed today:
- file-watcher.ts#L204 and #L244: per-file
local_erroris returned and never logged. #L182 only counts errors; #L139 forwards a batch-level error without logging it. - orchestrator.ts#L141: scan errors are collected into
batchErrorsand never logged. #L94/#L96 and #L164 switch toStandbywithout recording which files failed or why. - scanner.ts#L119: the error message includes the file path but only reaches the swallowing callback above.
- manager.ts#L427-L429 and #L441: superseded rebuild attempts return silently.
- file-watcher.ts#L204 and #L244: per-file
Reproduction
- Index a workspace until the state is
Indexed. - Make one file update fail once:
docker stop qdrant, save a source file, wait for the watcher batch to finish, thendocker start qdrant. - Save another source file so that a fully successful batch runs. Expected: the state returns to
Indexed. Actual: it staysStandby, andcodebase_searchkeeps failing withCurrent state: Standby. - Click Start Indexing. Expected: one clean restart. Actual: indexing restarts, but exthost.log shows the unhandled
CodeIndexManager not initializederror, and the embedder is validated twice.
Unit-level:
- Make the first
client.upsertcall inupsertPointsthrownew TypeError("fetch failed")→ the file fails with no retry. - Fire
onDidFinishBatchProcessingonce with alocal_errorfile, then with an all-success batch → the state staysStandby. - With services alive and state
Standby, dispatchstartIndexing→ two rebuilds and an unhandled rejection.
These are proposed steps; the incident above was observed live, not reproduced on purpose.
Acceptance criteria
Retry (part 1)
- Transient failures in a file's embed, upsert, delete, or verify steps are retried with bounded exponential backoff (keep 3 attempts / 500 ms base unless there is a reason to change it).
- "Transient" means connection-level errors (
fetch failed, ECONNRESET, ECONNREFUSED, ETIMEDOUT, closed socket), HTTP 5xx, and 429. Validation/4xx errors and parser failures are not retried. - Retries respect the abort signal, the write gate, and generation fencing: a superseded or cancelled attempt never writes after cancellation.
Recovery (part 2)
- One failed file does not keep the whole index in
Standbyonce that file later succeeds, is deleted, or is retried successfully; the latch is cleared accordingly. - Failed files are retried automatically with bounded backoff (for example, re-queued into a later watcher batch or a background reconciliation pass), and the state returns to
Indexedwithout a manual restart. - Decide and document what search does on a partial index: either allow
codebase_searchwith a "partial index" note, or keep refusing with an actionable message (which files failed and how to retry). - While files remain failed, the status shows how many failed plus at least one path and reason, and offers a retry.
Start Indexing (part 3)
- One click triggers exactly one rebuild-and-start sequence, from
Standbyand fromError. - No unhandled rejections from Start Indexing, Toggle Workspace Indexing, or the auto-enable default; failures are caught, logged, and reflected in the status.
- The
startIndexing()contract is clarified (for example: safe to await until services are started while the scan continues in the background, or every caller must attach.catch), and the doc comment is updated to match.
Logging (part 4)
- Code-index logs go to the Roo-Code output channel (or a dedicated
LogOutputChannel) with a[CodeIndex]prefix, so installed builds keep them. - Log every state change: old → new state, the status message, the source (scan end, watcher batch, stop, rebuild, error), and the attempt number.
- Log every failed file: workspace-relative path, step (read / parse / embed / upsert / delete / verify), error message, and whether it will be retried. Aggregate per batch so a mass failure doesn't flood the log. Log each retry and the final failure.
- Log a scan summary: files processed / skipped / failed, blocks found / indexed, duration, and why the scan ended partial.
- Log Start, Stop, and rebuild requests, including superseded attempts.
- Show the latest failure reason (failed count plus one file) in the indexing status text.
- Never log secrets or file contents — paths and error messages only.
Tests
- One transient upsert failure followed by success → the file completes; a persistent failure → fails after the maximum attempts; abort during backoff → stops promptly with no further writes.
- A watcher failure followed by success recovers; a scan with one failed file recovers after retry; a persistent failure stays visible with bounded retries.
- Start Indexing from
Standbywith live services, fromError, and a double click → exactly one rebuild and no unhandled rejection. - A failed file, a partial scan, and a state change each produce a log entry.
Constraints/Preferences
- Keep PR [code-index] Isolate parsing so parser failures stop indexing safely #34's protections: write gate, generation and attempt fencing (
currentAttempt/isCurrentAttempt), and preserved partial progress. - Don't stack another retry loop on top of the embedders' internal retries for the same error class.
- Don't hide persistent failures; they must stay visible and logged.
- Keep steady-state log noise low: no per-success lines by default (use debug or trace level for those).
- Suggested order: logging (part 4) and retry (part 1) first, so a recurrence is both less likely and recorded; then recovery (part 2) and Start Indexing (part 3).
- Coordinate status wording with [BUG] Make indexing stop status reflect what actually stopped #36.
Related: PR #34, #23, #35, #36. Consolidates #58, #59, and #60, which are closed as duplicates of this issue.
Activity
Merge pull request #67 from simurg79/fix/issue-57-code-index-recovery