Skip to content

Commit 576941c

Browse files
committed
fix(run-engine): don't mislabel DB errors as UnclassifiableWaitpointId in completeWaitpoint
forWaitpointCompletion resolves the owning store by probing the database, so a transient DB/infra error surfaced from that call was being caught and rethrown as UnclassifiableWaitpointId with a misleading "length matches neither cuid nor run-ops id" message, losing the original error's type, retryability, and error grouping. Narrow the catch so only a genuine id-classification failure (UnclassifiableRunId) becomes UnclassifiableWaitpointId; every other error (including DB connectivity failures) is rethrown unchanged.
1 parent c936c79 commit 576941c

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

internal-packages/run-engine/src/engine/systems/waitpointSystem.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { timeoutError, tryCatch } from "@trigger.dev/core/v3";
2-
import { WaitpointId } from "@trigger.dev/core/v3/isomorphic";
2+
import { UnclassifiableRunId, WaitpointId } from "@trigger.dev/core/v3/isomorphic";
33
import type {
44
PrismaClientOrTransaction,
55
TaskRun,
@@ -91,11 +91,24 @@ export class WaitpointSystem {
9191
try {
9292
store = await this.$.runStore.forWaitpointCompletion(id, { routeKind: "MANUAL" });
9393
} catch (error) {
94-
this.$.logger.error("completeWaitpoint: unclassifiable waitpointId", {
94+
// Only a genuine id-classification failure should become UnclassifiableWaitpointId.
95+
// forWaitpointCompletion also probes the DB to resolve the owning store, so a transient
96+
// database/infra error (e.g. can't reach the database) can surface here too. Those MUST
97+
// bubble up unchanged so they keep their original type, retryability, and error grouping
98+
// instead of being mislabelled as an unclassifiable id.
99+
if (error instanceof UnclassifiableRunId) {
100+
this.$.logger.error("completeWaitpoint: unclassifiable waitpointId", {
101+
waitpointId: id,
102+
error,
103+
});
104+
throw new UnclassifiableWaitpointId(id, { cause: error });
105+
}
106+
107+
this.$.logger.error("completeWaitpoint: error resolving waitpoint store", {
95108
waitpointId: id,
96109
error,
97110
});
98-
throw new UnclassifiableWaitpointId(id, { cause: error });
111+
throw error;
99112
}
100113

101114
// 1. Complete the Waitpoint (if not completed)

0 commit comments

Comments
 (0)