fix(sdk): guard against null output in wait token timeout error - #4542
fix(sdk): guard against null output in wait token timeout error#4542okxint wants to merge 2 commits into
Conversation
When a waitpoint token times out but has no output payload (output=null in the DB), data is undefined. Accessing data.message throws a TypeError that crashes the runtime before the timeout error is returned to the caller. Use optional chaining with a fallback message to match the pattern already used in sharedRuntimeManager for the same scenario.
🦋 Changeset detectedLatest commit: b265664 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Hi @okxint, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughThe SDK now prevents timeout error construction from failing when a waitpoint token response has null output or no message. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What?
wait.retrieveTokenandwait.forTokenboth setdata = undefinedwhen a waitpoint token'soutputis null/absent, then immediately accessdata.messagein the error path. This throws aTypeErrorthat crashes the runtime before the caller ever sees theWaitpointTimeoutError.Why?
A timed-out waitpoint with
outputIsError = truebutoutput = null(null stored in DB) sends nooutputfield from the API presenter. The existing code assumed output is always present whenoutputIsErroris true, butApiWaitpointPresenteralready handles this case at line 84, confirming the scenario is real.Fix
Use optional chaining with a fallback message (
data?.message ?? "Waitpoint timed out"), matching the patternsharedRuntimeManageralready uses for the identical case at line 292-302.Changes
packages/trigger-sdk/src/v3/wait.ts— two null guards inretrieveTokenandforToken.changeset/fix-wait-token-null-output-crash.md— patch changeset