diff --git a/core/.eslintrc.json b/core/.eslintrc.json index fa760cc0c..384bb348c 100644 --- a/core/.eslintrc.json +++ b/core/.eslintrc.json @@ -7,7 +7,7 @@ "rules": { "quotes": ["off", "double", {}], "@typescript-eslint/naming-convention": "off", - "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/no-floating-promises": "error", "import/order": "off", "curly": "off", "@typescript-eslint/semi": "off", diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index 2d3fe9eba..fd9cf2923 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -261,7 +261,9 @@ export class CompletionProvider { // Save to cache if (!outcome.cacheHit && helper.options.useCache) { - (await this.autocompleteCache).put(outcome.prefix, outcome.completion); + (await this.autocompleteCache) + .put(outcome.prefix, outcome.completion) + .catch((e) => console.warn(`Failed to save to cache: ${e.message}`)); } // When using the JetBrains extension, Mark as displayed diff --git a/core/autocomplete/context/ImportDefinitionsService.ts b/core/autocomplete/context/ImportDefinitionsService.ts index e2288138a..0115b443f 100644 --- a/core/autocomplete/context/ImportDefinitionsService.ts +++ b/core/autocomplete/context/ImportDefinitionsService.ts @@ -22,7 +22,13 @@ export class ImportDefinitionsService { constructor(private readonly ide: IDE) { ide.onDidChangeActiveTextEditor((filepath) => { - this.cache.initKey(filepath); + this.cache + .initKey(filepath) + .catch((e) => + console.warn( + `Failed to initialize ImportDefinitionService: ${e.message}`, + ), + ); }); } diff --git a/core/autocomplete/generation/ListenableGenerator.ts b/core/autocomplete/generation/ListenableGenerator.ts index e6b36019b..3fddb55a3 100644 --- a/core/autocomplete/generation/ListenableGenerator.ts +++ b/core/autocomplete/generation/ListenableGenerator.ts @@ -3,16 +3,18 @@ export class ListenableGenerator { private _buffer: T[] = []; private _listeners: Set<(value: T) => void> = new Set(); private _isEnded = false; - private _abortController: AbortController + private _abortController: AbortController; constructor( source: AsyncGenerator, private readonly onError: (e: any) => void, - abortController: AbortController + abortController: AbortController, ) { this._source = source; this._abortController = abortController; - this._start(); + this._start().catch((e) => + console.log(`Listenable generator failed: ${e.message}`), + ); } public cancel() { diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index c830ef10e..0c3167b7b 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -349,7 +349,7 @@ export class ConfigHandler { this.currentOrg = org; if (profileId) { - this.setSelectedProfileId(profileId); + await this.setSelectedProfileId(profileId); } else { this.currentProfile = org.currentProfile; await this.reloadConfig(); diff --git a/core/core.ts b/core/core.ts index 21208970d..e5c9eeab0 100644 --- a/core/core.ts +++ b/core/core.ts @@ -349,8 +349,8 @@ export class Core { return await this.configHandler.getSerializedConfig(); }); - on("config/ideSettingsUpdate", (msg) => { - this.configHandler.updateIdeSettings(msg.data); + on("config/ideSettingsUpdate", async (msg) => { + await this.configHandler.updateIdeSettings(msg.data); }); on("config/refreshProfiles", async (msg) => { @@ -389,7 +389,7 @@ export class Core { }); on("mcp/reloadServer", async (msg) => { - MCPManagerSingleton.getInstance().refreshConnection(msg.data.id); + await MCPManagerSingleton.getInstance().refreshConnection(msg.data.id); }); // Context providers on("context/addDocs", async (msg) => { @@ -743,7 +743,7 @@ export class Core { if (!config) { return false; } - + const llm = config?.selectedModelByRole.chat; if (!llm) { throw new Error("No chat model selected"); @@ -1034,10 +1034,9 @@ export class Core { } this.indexingCancellationController = new AbortController(); try { - for await (const update of (await this.codebaseIndexerPromise).refreshDirs( - paths, - this.indexingCancellationController.signal, - )) { + for await (const update of ( + await this.codebaseIndexerPromise + ).refreshDirs(paths, this.indexingCancellationController.signal)) { let updateToSend = { ...update }; void this.messenger.request("indexProgress", updateToSend); @@ -1067,10 +1066,10 @@ export class Core { return; } this.indexingCancellationController = new AbortController(); - try{ - for await (const update of (await this.codebaseIndexerPromise).refreshFiles( - files, - )) { + try { + for await (const update of ( + await this.codebaseIndexerPromise + ).refreshFiles(files)) { let updateToSend = { ...update }; void this.messenger.request("indexProgress", updateToSend); @@ -1093,18 +1092,18 @@ export class Core { // private handleIndexingError(e: any) { - if (e instanceof LLMError) { - // Need to report this specific error to the IDE for special handling - this.messenger.request("reportError", e); - } - // broadcast indexing error - let updateToSend: IndexingProgressUpdate = { - progress: 0, - status: "failed", - desc: e.message, - }; - void this.messenger.request("indexProgress", updateToSend); - this.codebaseIndexingState = updateToSend; - void this.sendIndexingErrorTelemetry(updateToSend); + if (e instanceof LLMError) { + // Need to report this specific error to the IDE for special handling + void this.messenger.request("reportError", e); + } + // broadcast indexing error + let updateToSend: IndexingProgressUpdate = { + progress: 0, + status: "failed", + desc: e.message, + }; + void this.messenger.request("indexProgress", updateToSend); + this.codebaseIndexingState = updateToSend; + void this.sendIndexingErrorTelemetry(updateToSend); } } diff --git a/core/indexing/CodeSnippetsIndex.ts b/core/indexing/CodeSnippetsIndex.ts index bf733b5ce..9a2da5008 100644 --- a/core/indexing/CodeSnippetsIndex.ts +++ b/core/indexing/CodeSnippetsIndex.ts @@ -57,7 +57,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { FOREIGN KEY (snippetId) REFERENCES code_snippets (id) )`); - migrate("add_signature_column", async () => { + await migrate("add_signature_column", async () => { const tableInfo = await db.all("PRAGMA table_info(code_snippets)"); const signatureColumnExists = tableInfo.some( (column) => column.name === "signature", @@ -71,7 +71,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { } }); - migrate("delete_duplicate_code_snippets", async () => { + await migrate("delete_duplicate_code_snippets", async () => { // Delete duplicate entries in code_snippets await db.exec(` DELETE FROM code_snippets @@ -256,7 +256,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { progress: i / results.compute.length, status: "indexing", }; - markComplete([compute], IndexResultType.Compute); + await markComplete([compute], IndexResultType.Compute); } // Delete @@ -278,7 +278,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { ); } - markComplete([del], IndexResultType.Delete); + await markComplete([del], IndexResultType.Delete); } // Add tag @@ -313,7 +313,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { ); } - markComplete([results.addTag[i]], IndexResultType.AddTag); + await markComplete([results.addTag[i]], IndexResultType.AddTag); } // Remove tag @@ -343,7 +343,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { ); } - markComplete([results.removeTag[i]], IndexResultType.RemoveTag); + await markComplete([results.removeTag[i]], IndexResultType.RemoveTag); } } diff --git a/core/indexing/TestCodebaseIndex.ts b/core/indexing/TestCodebaseIndex.ts index e36dff7ce..86b22ab98 100644 --- a/core/indexing/TestCodebaseIndex.ts +++ b/core/indexing/TestCodebaseIndex.ts @@ -48,10 +48,10 @@ export class TestCodebaseIndex implements CodebaseIndex { ); } - markComplete(results.compute, IndexResultType.Compute); - markComplete(results.addTag, IndexResultType.AddTag); - markComplete(results.del, IndexResultType.Delete); - markComplete(results.removeTag, IndexResultType.RemoveTag); + await markComplete(results.compute, IndexResultType.Compute); + await markComplete(results.addTag, IndexResultType.AddTag); + await markComplete(results.del, IndexResultType.Delete); + await markComplete(results.removeTag, IndexResultType.RemoveTag); } async getIndexedFilesForTags(tags: IndexTag[]): Promise { diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index cc9eef842..d82c34b20 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -510,7 +510,7 @@ export default class DocsService { } catch (e) { if (e instanceof LLMError) { // Report the error to the IDE - this.messenger?.request("reportError", e); + await this.messenger?.request("reportError", e); } this.handleStatusUpdate({ ...fixedStatus, diff --git a/core/llm/asyncEncoder.test.ts b/core/llm/asyncEncoder.test.ts index 9ed5eb80a..0b02b3d5a 100644 --- a/core/llm/asyncEncoder.test.ts +++ b/core/llm/asyncEncoder.test.ts @@ -1,4 +1,4 @@ -import { LlamaAsyncEncoder, GPTAsyncEncoder } from "./asyncEncoder"; +import { GPTAsyncEncoder, LlamaAsyncEncoder } from "./asyncEncoder"; describe("llama encoder", () => { var tokenizer: LlamaAsyncEncoder; @@ -8,7 +8,7 @@ describe("llama encoder", () => { }); afterAll(() => { - tokenizer.close(); + tokenizer.close().catch((e) => {}); }); test("hello world", async () => { @@ -30,7 +30,7 @@ describe("tiktoken encoder", () => { }); afterAll(() => { - tokenizer.close(); + tokenizer.close().catch((e) => {}); }); test("hello world", async () => { diff --git a/core/llm/llms/Docker.ts b/core/llm/llms/Docker.ts index 131f45b14..3860a9b9e 100644 --- a/core/llm/llms/Docker.ts +++ b/core/llm/llms/Docker.ts @@ -60,7 +60,7 @@ class Docker extends OpenAI implements ModelInstaller { } // Check if Docker Model Runner is active and enable it if needed - this.ensureModelRunnerEnabled(); + this.ensureModelRunnerEnabled().catch((e) => {}); } /** @@ -198,7 +198,7 @@ class Docker extends OpenAI implements ModelInstaller { return { success: true, stdout, stderr }; } catch (error) { console.error(`Failed to install Docker model ${targetModel}:`, error); -// Fix: Type check the error before accessing message property + // Fix: Type check the error before accessing message property const errorMessage = error instanceof Error ? error.message : String(error); throw new Error( diff --git a/core/llm/llms/HuggingFaceTGI.ts b/core/llm/llms/HuggingFaceTGI.ts index 481532f95..c9812cca3 100644 --- a/core/llm/llms/HuggingFaceTGI.ts +++ b/core/llm/llms/HuggingFaceTGI.ts @@ -14,18 +14,22 @@ class HuggingFaceTGI extends BaseLLM { this.fetch(new URL("info", this.apiBase), { method: "GET", - }).then(async (response) => { - if (response.status !== 200) { - console.warn( - "Error calling Hugging Face TGI /info endpoint: ", - await response.text(), - ); - return; - } - const json = await response.json(); - this.model = json.model_id; - this.contextLength = Number.parseInt(json.max_input_length); - }); + }) + .then(async (response) => { + if (response.status !== 200) { + console.warn( + "Error calling Hugging Face TGI /info endpoint: ", + await response.text(), + ); + return; + } + const json = await response.json(); + this.model = json.model_id; + this.contextLength = Number.parseInt(json.max_input_length); + }) + .catch((e) => { + console.log(`Failed to list models for HuggingFace TGI: ${e.message}`); + }); } private _convertArgs(options: CompletionOptions, prompt: string) { diff --git a/core/llm/llms/VertexAI.ts b/core/llm/llms/VertexAI.ts index b70fe179a..97cb40e25 100644 --- a/core/llm/llms/VertexAI.ts +++ b/core/llm/llms/VertexAI.ts @@ -22,7 +22,11 @@ class VertexAI extends BaseLLM { private clientPromise = new GoogleAuth({ scopes: "https://www.googleapis.com/auth/cloud-platform", - }).getClient(); + }) + .getClient() + .catch((e) => { + console.warn(`Failed to load credentials for Vertex AI: ${e.message}`); + }); private static getDefaultApiBaseFrom(options: LLMOptions) { const { region, projectId } = options; diff --git a/core/llm/llms/Vllm.ts b/core/llm/llms/Vllm.ts index 7273a67f6..b237b4c7e 100644 --- a/core/llm/llms/Vllm.ts +++ b/core/llm/llms/Vllm.ts @@ -16,19 +16,23 @@ class Vllm extends OpenAI { this.fetch(this._getEndpoint("models"), { method: "GET", headers: this._getHeaders(), - }).then(async (response) => { - if (response.status !== 200) { - console.warn( - "Error calling vLLM /models endpoint: ", - await response.text(), - ); - return; - } - const json = await response.json(); - const data = json.data[0]; - this.model = data.id; - this.contextLength = Number.parseInt(data.max_model_len); - }); + }) + .then(async (response) => { + if (response.status !== 200) { + console.warn( + "Error calling vLLM /models endpoint: ", + await response.text(), + ); + return; + } + const json = await response.json(); + const data = json.data[0]; + this.model = data.id; + this.contextLength = Number.parseInt(data.max_model_len); + }) + .catch((e) => { + console.log(`Failed to list models for vLLM: ${e.message}`); + }); } }