Skip to content

Commit

Permalink
Add new internal error for very outdated SDK versions (#1453)
Browse files Browse the repository at this point in the history
* add outdated sdk error and crash outdated runs instead of staying queued forever

* add changeset
  • Loading branch information
nicktrn authored Nov 1, 2024
1 parent 41f5261 commit 58def05
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-mugs-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---

Add outdated SDK error
6 changes: 6 additions & 0 deletions apps/webapp/app/v3/marqs/sharedQueueConsumer.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ProdTaskRunExecution,
ProdTaskRunExecutionPayload,
TaskRunError,
TaskRunErrorCodes,
TaskRunExecution,
TaskRunExecutionLazyAttemptPayload,
TaskRunExecutionResult,
Expand Down Expand Up @@ -519,6 +520,11 @@ export class SharedQueueConsumer {
taskRun: lockedTaskRun.id,
});

const service = new CrashTaskRunService();
await service.call(lockedTaskRun.id, {
errorCode: TaskRunErrorCodes.OUTDATED_SDK_VERSION,
});

await this.#ackAndDoMoreWork(message.messageId);
return;
}
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/v3/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export function shouldRetryError(error: TaskRunError): boolean {
case "MAX_DURATION_EXCEEDED":
case "DISK_SPACE_EXCEEDED":
case "TASK_RUN_HEARTBEAT_TIMEOUT":
case "OUTDATED_SDK_VERSION":
return false;

case "GRACEFUL_EXIT_TIMEOUT":
Expand Down Expand Up @@ -428,6 +429,14 @@ const prettyInternalErrors: Partial<
magic: "CONTACT_FORM",
},
},
OUTDATED_SDK_VERSION: {
message:
"Your task is using an outdated version of the SDK. Please upgrade to the latest version.",
link: {
name: "Beta upgrade guide",
href: links.docs.upgrade.beta,
},
},
};

const getPrettyTaskRunError = (code: TaskRunInternalError["code"]): TaskRunInternalError => {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/v3/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export const links = {
machines: {
home: "https://trigger.dev/docs/v3/machines",
},
upgrade: {
beta: "https://trigger.dev/docs/upgrading-beta",
},
},
site: {
home: "https://trigger.dev",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/v3/schemas/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const TaskRunInternalError = z.object({
"DISK_SPACE_EXCEEDED",
"POD_EVICTED",
"POD_UNKNOWN_ERROR",
"OUTDATED_SDK_VERSION",
]),
message: z.string().optional(),
stackTrace: z.string().optional(),
Expand Down

0 comments on commit 58def05

Please sign in to comment.