Skip to content

Code indexing gets stuck in error state when Qdrant is unavailable at startupΒ #6660

@hannesrudolph

Description

@hannesrudolph

App Version

v3.25.6

API Provider

Not Applicable / Other

Model Used

N/A

πŸ” Steps to Reproduce

  1. Start VSCode instance without starting docker qdrant instance
  2. Get Error - Failed during initial scan: fetch failed error in code indexing popup. This is not the bug, this is normal behaviour
  3. Start up docker qdrant instance
  4. Press "Start Indexing", "Error - Failed during initial scan: fetch failed" error persists
  5. Reload developer window and indexing starts automatically as it should

πŸ’₯ Outcome Summary

Expected "Start Indexing" button to retry connection and start indexing once Qdrant is available, but got persistent error state requiring developer window reload.

πŸ“„ Relevant Logs or Errors (Optional)

Error - Failed during initial scan: fetch failed

πŸ” Comprehensive Issue Scoping

Root Cause / Implementation Target

The CodeIndexManager enters an error state when Qdrant is unavailable during initial validation. When the user clicks "Start Indexing" after Qdrant becomes available, the system doesn't clear this error state before attempting to reinitialize, causing the operation to fail.

Affected Components

Current Implementation Analysis

The function at line 273 in manager.ts sets error state when validation fails:

this._stateManager.setSystemState("Error", errorMessage)

But when "Start Indexing" is clicked (webviewMessageHandler.ts line 2202-2204), it only checks if manager is initialized, not if it's in error state.

Proposed Implementation

Step 1: Add error recovery method to CodeIndexManager

  • File: src/services/code-index/manager.ts
  • Add new method after line 180:
public async recoverFromError(): Promise<void> {
    // Clear error state
    this._stateManager.setSystemState("Standby", "")
    // Force re-initialization
    this._configManager = undefined
    this._serviceFactory = undefined
    this._orchestrator = undefined
    this._searchService = undefined
}

Step 2: Update startIndexing handler

  • File: src/core/webview/webviewMessageHandler.ts
  • Modify lines 2200-2206 to check for error state:
if (manager.isFeatureEnabled && manager.isFeatureConfigured) {
    // Check if in error state and recover
    const currentStatus = manager.getCurrentStatus()
    if (currentStatus.systemStatus === "Error") {
        await manager.recoverFromError()
    }
    
    if (!manager.isInitialized) {
        await manager.initialize(provider.contextProxy)
    }
    
    manager.startIndexing()
}

Testing Requirements

  • Unit Tests:
    • Test case 1: Verify recoverFromError clears error state
    • Test case 2: Verify startIndexing recovers from error state
  • Edge Cases:
    • Edge case 1: Multiple rapid clicks on "Start Indexing"
    • Edge case 2: Qdrant becomes unavailable during recovery

Performance Impact

  • Expected performance change: Neutral
  • Benchmarking needed: No
  • Optimization opportunities: None identified

Security Considerations

  • Input validation requirements: None (existing validation sufficient)
  • Authentication/Authorization changes: None
  • Data exposure risks: None

Migration Strategy

Not applicable - this is a bug fix with no data migration needed.

Rollback Plan

If issues arise, revert the two file changes. No data or configuration changes are involved.

Dependencies and Breaking Changes

  • External dependencies affected: None
  • API contract changes: None (new method is internal)
  • Breaking changes for users: None

Metadata

Metadata

Assignees

Labels

Issue - In ProgressSomeone is actively working on this. Should link to a PR soon.bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions