Skip to content

fix(sdk): guard against null output in wait token timeout error - #4542

Closed
okxint wants to merge 2 commits into
triggerdotdev:mainfrom
okxint:fix/wait-token-crash-on-null-output
Closed

fix(sdk): guard against null output in wait token timeout error#4542
okxint wants to merge 2 commits into
triggerdotdev:mainfrom
okxint:fix/wait-token-crash-on-null-output

Conversation

@okxint

@okxint okxint commented Aug 9, 2026

Copy link
Copy Markdown

What?

wait.retrieveToken and wait.forToken both set data = undefined when a waitpoint token's output is null/absent, then immediately access data.message in the error path. This throws a TypeError that crashes the runtime before the caller ever sees the WaitpointTimeoutError.

Why?

A timed-out waitpoint with outputIsError = true but output = null (null stored in DB) sends no output field from the API presenter. The existing code assumed output is always present when outputIsError is true, but ApiWaitpointPresenter already 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 pattern sharedRuntimeManager already uses for the identical case at line 292-302.

Changes

  • packages/trigger-sdk/src/v3/wait.ts — two null guards in retrieveToken and forToken
  • .changeset/fix-wait-token-null-output-crash.md — patch changeset

okxint added 2 commits August 9, 2026 18:26
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-bot

changeset-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b265664

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@trigger.dev/sdk Patch
@trigger.dev/python Patch
@internal/dashboard-agent Patch
@internal/sdk-compat-tests Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/react-hooks Patch
@trigger.dev/redis-worker Patch
@trigger.dev/rsc Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@trigger.dev/rbac Patch
@trigger.dev/sso Patch
trigger.dev Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/metrics-pipeline Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/run-store Patch
@internal/schedule-engine Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch

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

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot closed this Aug 9, 2026
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cd97c487-b6b9-4447-b7bc-5cf8e1eee6f0

📥 Commits

Reviewing files that changed from the base of the PR and between 90e8bd5 and b265664.

📒 Files selected for processing (2)
  • .changeset/fix-wait-token-null-output-crash.md
  • packages/trigger-sdk/src/v3/wait.ts

Walkthrough

The SDK now prevents timeout error construction from failing when a waitpoint token response has null output or no message. retrieveToken and wait.forToken use "Waitpoint timed out" when the response message is unavailable. A patch changeset documents the fix.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant