error on no-floating-promises in core

This commit is contained in:
Nate 2025-04-29 15:11:35 -07:00
parent 7c8d5588e4
commit cd9d63643f
14 changed files with 95 additions and 74 deletions

View file

@ -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",

View file

@ -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

View file

@ -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}`,
),
);
});
}

View file

@ -3,16 +3,18 @@ export class ListenableGenerator<T> {
private _buffer: T[] = [];
private _listeners: Set<(value: T) => void> = new Set();
private _isEnded = false;
private _abortController: AbortController
private _abortController: AbortController;
constructor(
source: AsyncGenerator<T>,
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() {

View file

@ -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();

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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<string[]> {

View file

@ -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,

View file

@ -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 () => {

View file

@ -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(

View file

@ -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) {

View file

@ -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;

View file

@ -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}`);
});
}
}