From 5b9feccc69efa8631258c499b461f9ed7a25df09 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Fri, 8 Aug 2025 12:42:08 +0530 Subject: [PATCH 1/2] fix: abort controller before clearing --- core/indexing/CodebaseIndexer.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index 6e1dab530..b28ece8da 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -735,6 +735,7 @@ export class CodebaseIndexer { }); } if (this.indexingCancellationController === localController) { + this.indexingCancellationController.abort(); // abort before clearing to prevent race condition (multiple starts) this.indexingCancellationController = undefined; } } From cec4f0f4a3ed5fa35f09586dd3f4e932c27b4044 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 12 Aug 2025 13:05:42 +0530 Subject: [PATCH 2/2] abort controller should not be undefined --- core/indexing/CodebaseIndexer.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index b28ece8da..54e84bf17 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -56,7 +56,7 @@ export class CodebaseIndexer { // and only need to `await` it for tests. public initPromise: Promise; private config!: ContinueConfig; - private indexingCancellationController: AbortController | undefined; + private indexingCancellationController: AbortController; private codebaseIndexingState: IndexingProgressUpdate; private readonly pauseToken: PauseToken; @@ -97,6 +97,9 @@ export class CodebaseIndexer { this.pauseToken = new PauseToken(initialPaused); this.initPromise = this.init(configHandler); + + this.indexingCancellationController = new AbortController(); + this.indexingCancellationController.abort(); // initialize and abort so that a new one can be created } // Initialization - load config and attach config listener @@ -693,7 +696,7 @@ export class CodebaseIndexer { } public async refreshCodebaseIndex(paths: string[]) { - if (this.indexingCancellationController) { + if (!this.indexingCancellationController.signal.aborted) { this.indexingCancellationController.abort(); } const localController = new AbortController(); @@ -735,17 +738,13 @@ export class CodebaseIndexer { }); } if (this.indexingCancellationController === localController) { - this.indexingCancellationController.abort(); // abort before clearing to prevent race condition (multiple starts) - this.indexingCancellationController = undefined; + this.indexingCancellationController.abort(); } } public async refreshCodebaseIndexFiles(files: string[]) { // Can be cancelled by codebase index but not vice versa - if ( - this.indexingCancellationController && - !this.indexingCancellationController.signal.aborted - ) { + if (!this.indexingCancellationController.signal.aborted) { return; } const localController = new AbortController(); @@ -771,7 +770,7 @@ export class CodebaseIndexer { }); } if (this.indexingCancellationController === localController) { - this.indexingCancellationController = undefined; + this.indexingCancellationController.abort(); } }