Skip to content

Commit 11f2832

Browse files
committed
Fix for detecting internal errors
1 parent fd04ed5 commit 11f2832

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

packages/core/src/v3/errors.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class InternalError extends Error {
3131
skipRetrying?: boolean;
3232
}) {
3333
super(`${code}: ${message ?? "No message"}`);
34-
this.name = "InternalError";
34+
this.name = "TriggerInternalError";
3535
this.code = code;
3636
this.message = message ?? "InternalError";
3737

@@ -43,6 +43,10 @@ export class InternalError extends Error {
4343
}
4444
}
4545

46+
export function isInternalError(error: unknown): error is InternalError {
47+
return error instanceof Error && error.name === "TriggerInternalError";
48+
}
49+
4650
export class AbortTaskRunError extends Error {
4751
constructor(message: string) {
4852
super(message);
@@ -63,7 +67,7 @@ export class TaskPayloadParsedError extends Error {
6367
}
6468

6569
export function parseError(error: unknown): TaskRunError {
66-
if (error instanceof InternalError) {
70+
if (isInternalError(error)) {
6771
return {
6872
type: "INTERNAL_ERROR",
6973
code: error.code,

packages/core/src/v3/workers/taskExecutor.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { SpanKind } from "@opentelemetry/api";
22
import { VERSION } from "../../version.js";
33
import { ApiError, RateLimitError } from "../apiClient/errors.js";
44
import { ConsoleInterceptor } from "../consoleInterceptor.js";
5-
import { InternalError, parseError, sanitizeError, TaskPayloadParsedError } from "../errors.js";
5+
import {
6+
InternalError,
7+
isInternalError,
8+
parseError,
9+
sanitizeError,
10+
TaskPayloadParsedError,
11+
} from "../errors.js";
612
import { runMetadata, TriggerConfig, waitUntil } from "../index.js";
713
import { recordSpanException, TracingSDK } from "../otel/index.js";
814
import {
@@ -536,11 +542,13 @@ export class TaskExecutor {
536542

537543
if (
538544
error instanceof Error &&
539-
(error.name === "AbortTaskRunError" ||
540-
error.name === "TaskPayloadParsedError" ||
541-
("skipRetrying" in error && error.skipRetrying === true))
545+
(error.name === "AbortTaskRunError" || error.name === "TaskPayloadParsedError")
542546
) {
543-
return { status: "skipped", error: error instanceof InternalError ? error : undefined };
547+
return { status: "skipped" };
548+
}
549+
550+
if (isInternalError(error) && error.skipRetrying) {
551+
return { status: "skipped", error };
544552
}
545553

546554
if (execution.run.maxAttempts) {

0 commit comments

Comments
 (0)