Skip to content

Race condition in concurrent indexing requests #253

@Retengart

Description

@Retengart

Problem

Check for existing indexing and setting indexing state is not atomic.

Current Behavior

// handlers.ts:192-200
if (this.snapshotManager.getIndexingCodebases().includes(absolutePath)) {
    return { /* already indexing */ };
}
// ... validation code ...
this.snapshotManager.setCodebaseIndexing(absolutePath, 0);

Gap between check and set allows race condition.

Impact

Two concurrent index requests for same path may both pass the check and start parallel indexing jobs.

Expected Behavior

Atomic check-and-set, or use mutex/lock for indexing operations.

Location

  • packages/mcp/src/handlers.ts:192-282

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions