Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/runs-retrieve-request-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@trigger.dev/sdk": patch
---

feat(runs): add clientConfig support to runs.retrieve() and runs.poll()

This change updates `runs.retrieve()` and `runs.poll()` to accept `TriggerApiRequestOptions` instead of `ApiRequestOptions`, enabling per-request client configuration via the `clientConfig` property.

This aligns `runs.retrieve()` with other SDK methods like `tasks.trigger()` that already support `clientConfig` for multi-project scenarios where different access tokens are needed per request.

Fixes #2769
7 changes: 4 additions & 3 deletions packages/trigger-sdk/src/v3/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
AsyncIterableStream,
ApiPromise,
RealtimeRunSkipColumns,
TriggerApiRequestOptions,
} from "@trigger.dev/core/v3";
import {
CanceledRunResponse,
Expand Down Expand Up @@ -167,9 +168,9 @@ type RunId<TRunId> = TRunId extends AnyRunHandle | AnyBatchedRunHandle

function retrieveRun<TRunId extends AnyRunHandle | AnyBatchedRunHandle | AnyTask | string>(
runId: RunId<TRunId>,
requestOptions?: ApiRequestOptions
requestOptions?: TriggerApiRequestOptions
): ApiPromise<RetrieveRunResult<TRunId>> {
const apiClient = apiClientManager.clientOrThrow();
const apiClient = apiClientManager.clientOrThrow(requestOptions?.clientConfig);

const $requestOptions = mergeRequestOptions(
{
Expand Down Expand Up @@ -316,7 +317,7 @@ const MAX_POLL_ATTEMPTS = 500;
async function poll<TRunId extends AnyRunHandle | AnyTask | string>(
runId: RunId<TRunId>,
options?: { pollIntervalMs?: number },
requestOptions?: ApiRequestOptions
requestOptions?: TriggerApiRequestOptions
) {
let attempts = 0;

Expand Down