Skip to content

Commit e3db257

Browse files
committed
Fix error stack traces
1 parent de1cc86 commit e3db257

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

.changeset/clever-apes-collect.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
Fix error stack traces

packages/core/src/v3/errors.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,32 +69,27 @@ export function correctErrorStackTrace(
6969
.join("\n");
7070
}
7171

72-
function correctStackTraceLine(line: string, projectDir?: string) {
73-
const regex = /at (.*?) \(?file:\/\/(\/.*?\.ts):(\d+):(\d+)\)?/;
74-
75-
const match = regex.exec(line);
76-
77-
if (!match) {
78-
return;
79-
}
72+
const LINES_TO_IGNORE = [
73+
/ConsoleInterceptor/,
74+
/TriggerTracer/,
75+
/TaskExecutor/,
76+
/EXECUTE_TASK_RUN/,
77+
/@trigger.dev\/core/,
78+
/safeJsonProcess/,
79+
/__entryPoint.ts/,
80+
];
8081

81-
const [_, identifier, path, lineNum, colNum] = match;
82-
83-
if (!path) {
84-
return;
85-
}
86-
87-
// Check to see if the file name is __entryPoint.ts, if it is we can remove it
88-
if (nodePath.basename(path) === "__entryPoint.ts") {
82+
function correctStackTraceLine(line: string, projectDir?: string) {
83+
if (LINES_TO_IGNORE.some((regex) => regex.test(line))) {
8984
return;
9085
}
9186

9287
// Check to see if the path is inside the project directory
93-
if (projectDir && !path.includes(projectDir)) {
88+
if (projectDir && !line.includes(projectDir)) {
9489
return;
9590
}
9691

97-
return line;
92+
return line.trim();
9893
}
9994

10095
export function groupTaskMetadataIssuesByTask(tasks: any, issues: z.ZodIssue[]) {

0 commit comments

Comments
 (0)