Skip to content

Commit 3c4f4de

Browse files
committed
extract functions responsible for errors
1 parent 296ee4f commit 3c4f4de

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

core/core.ts

+1
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ export class Core {
695695
"indexing_error",
696696
{
697697
error: update.desc,
698+
stack: update.debugInfo,
698699
},
699700
false,
700701
);

core/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface IndexingProgressUpdate {
3939
desc: string;
4040
shouldClearIndexes?: boolean;
4141
status: "loading" | "indexing" | "done" | "failed" | "paused" | "disabled";
42+
debugInfo?: string;
4243
}
4344

4445
export type PromptTemplate =

core/indexing/CodebaseIndexer.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import * as fs from "fs/promises";
12
import { ConfigHandler } from "../config/ConfigHandler.js";
23
import { IContinueServerClient } from "../continueServer/interface.js";
34
import { IDE, IndexTag, IndexingProgressUpdate } from "../index.js";
5+
import { extractMinimalStackTraceInfo } from "../util/extractMinimalStackTraceInfo.js";
46
import { getIndexSqlitePath, getLanceDbPath } from "../util/paths.js";
57
import { ChunkCodebaseIndex } from "./chunk/ChunkCodebaseIndex.js";
68
import { CodeSnippetsCodebaseIndex } from "./CodeSnippetsIndex.js";
@@ -13,7 +15,6 @@ import {
1315
RefreshIndexResults,
1416
} from "./types.js";
1517
import { walkDirAsync } from "./walkDir.js";
16-
import * as fs from "fs/promises";
1718

1819
export class PauseToken {
1920
constructor(private _paused: boolean) {}
@@ -259,6 +260,7 @@ export class CodebaseIndexer {
259260
progress: 0,
260261
desc: `Indexing failed: ${err}`,
261262
status: "failed",
263+
debugInfo: extractMinimalStackTraceInfo((err as any)?.stack),
262264
};
263265
}
264266

@@ -282,6 +284,7 @@ export class CodebaseIndexer {
282284
desc: errMsg,
283285
status: "failed",
284286
shouldClearIndexes,
287+
debugInfo: extractMinimalStackTraceInfo(err.stack),
285288
};
286289
}
287290

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* It's helpful to know what functions errors occur in, but absolute
3+
* file paths are sensitive information, so we want to remove them.
4+
* @param stack The stack trace to extract minimal information from.
5+
* @returns A string containing the minimal stack trace information.
6+
*/
7+
export function extractMinimalStackTraceInfo(stack: unknown): string {
8+
if (typeof stack !== "string") return "";
9+
const lines = stack.split("\n");
10+
const minimalLines = lines.filter((line) => {
11+
return line.trimStart().startsWith("at ") && !line.includes("node_modules");
12+
});
13+
return minimalLines
14+
.map((line) => line.trimStart().replace("at ", "").split(" (").slice(0, 1))
15+
.join(", ");
16+
}

extensions/vscode/src/webviewProtocol.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FromWebviewProtocol, ToWebviewProtocol } from "core/protocol";
2+
import { extractMinimalStackTraceInfo } from "core/util/extractMinimalStackTraceInfo";
23
import { Message } from "core/util/messenger";
34
import { Telemetry } from "core/util/posthog";
45
import fs from "node:fs";
@@ -159,6 +160,7 @@ export class VsCodeWebviewProtocol
159160
{
160161
messageType: msg.messageType,
161162
errorMsg: message.split("\n\n")[0],
163+
stack: extractMinimalStackTraceInfo(e.stack),
162164
},
163165
false,
164166
);

0 commit comments

Comments
 (0)