diff --git a/.changeset/fix-wait-token-null-output-crash.md b/.changeset/fix-wait-token-null-output-crash.md new file mode 100644 index 00000000000..bd8091df07a --- /dev/null +++ b/.changeset/fix-wait-token-null-output-crash.md @@ -0,0 +1,5 @@ +--- +"@trigger.dev/sdk": patch +--- + +Fix crash when a timed-out waitpoint token has no output payload. When `result.output` is null, `data` is `undefined` and accessing `data.message` throws a `TypeError` before the timeout error reaches the caller. Uses optional chaining with a fallback message, matching the pattern already used in `sharedRuntimeManager` for the same case. diff --git a/packages/trigger-sdk/src/v3/wait.ts b/packages/trigger-sdk/src/v3/wait.ts index 934870b277e..47a0b53ec35 100644 --- a/packages/trigger-sdk/src/v3/wait.ts +++ b/packages/trigger-sdk/src/v3/wait.ts @@ -269,7 +269,7 @@ async function retrieveToken( let output: T | undefined = undefined; if (result.outputIsError) { - error = new WaitpointTimeoutError(data.message); + error = new WaitpointTimeoutError(data?.message ?? "Waitpoint timed out"); } else { output = data as T; } @@ -615,7 +615,7 @@ export const wait = { output: data, } as WaitpointTokenTypedResult; } else { - const error = new WaitpointTimeoutError(data.message); + const error = new WaitpointTimeoutError(data?.message ?? "Waitpoint timed out"); span.recordException(error); span.setStatus({