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.
This commit is contained in:
Claude
2026-07-14 13:30:41 +00:00
parent c936c79e39
commit 576941c422
@@ -1,5 +1,5 @@
import { timeoutError, tryCatch } from "@trigger.dev/core/v3";
import { WaitpointId } from "@trigger.dev/core/v3/isomorphic";
import { UnclassifiableRunId, WaitpointId } from "@trigger.dev/core/v3/isomorphic";
import type {
PrismaClientOrTransaction,
TaskRun,
@@ -91,11 +91,24 @@ export class WaitpointSystem {
try {
store = await this.$.runStore.forWaitpointCompletion(id, { routeKind: "MANUAL" });
} catch (error) {
this.$.logger.error("completeWaitpoint: unclassifiable waitpointId", {
// Only a genuine id-classification failure should become UnclassifiableWaitpointId.
// forWaitpointCompletion also probes the DB to resolve the owning store, so a transient
// database/infra error (e.g. can't reach the database) can surface here too. Those MUST
// bubble up unchanged so they keep their original type, retryability, and error grouping
// instead of being mislabelled as an unclassifiable id.
if (error instanceof UnclassifiableRunId) {
this.$.logger.error("completeWaitpoint: unclassifiable waitpointId", {
waitpointId: id,
error,
});
throw new UnclassifiableWaitpointId(id, { cause: error });
}
this.$.logger.error("completeWaitpoint: error resolving waitpoint store", {
waitpointId: id,
error,
});
throw new UnclassifiableWaitpointId(id, { cause: error });
throw error;
}
// 1. Complete the Waitpoint (if not completed)