Fix error stack traces

This commit is contained in:
Eric Allam
2024-04-24 14:18:53 +01:00
parent de1cc868e3
commit e3db257397
2 changed files with 18 additions and 18 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---
Fix error stack traces
+13 -18
View File
@@ -69,32 +69,27 @@ export function correctErrorStackTrace(
.join("\n");
}
const LINES_TO_IGNORE = [
/ConsoleInterceptor/,
/TriggerTracer/,
/TaskExecutor/,
/EXECUTE_TASK_RUN/,
/@trigger.dev\/core/,
/safeJsonProcess/,
/__entryPoint.ts/,
];
function correctStackTraceLine(line: string, projectDir?: string) {
const regex = /at (.*?) \(?file:\/\/(\/.*?\.ts):(\d+):(\d+)\)?/;
const match = regex.exec(line);
if (!match) {
return;
}
const [_, identifier, path, lineNum, colNum] = match;
if (!path) {
return;
}
// Check to see if the file name is __entryPoint.ts, if it is we can remove it
if (nodePath.basename(path) === "__entryPoint.ts") {
if (LINES_TO_IGNORE.some((regex) => regex.test(line))) {
return;
}
// Check to see if the path is inside the project directory
if (projectDir && !path.includes(projectDir)) {
if (projectDir && !line.includes(projectDir)) {
return;
}
return line;
return line.trim();
}
export function groupTaskMetadataIssuesByTask(tasks: any, issues: z.ZodIssue[]) {