abort controller should not be undefined
This commit is contained in:
parent
baefa153ca
commit
cec4f0f4a3
1 changed files with 8 additions and 9 deletions
|
|
@ -56,7 +56,7 @@ export class CodebaseIndexer {
|
|||
// and only need to `await` it for tests.
|
||||
public initPromise: Promise<void>;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue