Skip to content

Commit c3656a5

Browse files
refactor: avoid double-resolving accessToken in sendMessages
Use the already-resolved token when creating ApiClient instead of calling resolveAccessToken() again through getApiClient(). Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent a17cad9 commit c3656a5

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

packages/ai/src/transport.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ export class TriggerChatTransport implements ChatTransport<UIMessage> {
9090
this.streamTimeoutSeconds = options.streamTimeoutSeconds ?? DEFAULT_STREAM_TIMEOUT_SECONDS;
9191
}
9292

93-
private getApiClient(): ApiClient {
94-
return new ApiClient(this.baseURL, this.resolveAccessToken());
95-
}
96-
9793
/**
9894
* Sends messages to a Trigger.dev task and returns a streaming response.
9995
*
@@ -125,8 +121,8 @@ export class TriggerChatTransport implements ChatTransport<UIMessage> {
125121

126122
const currentToken = this.resolveAccessToken();
127123

128-
// Trigger the task
129-
const apiClient = this.getApiClient();
124+
// Trigger the task — use the already-resolved token directly
125+
const apiClient = new ApiClient(this.baseURL, currentToken);
130126
const triggerResponse = await apiClient.triggerTask(this.taskId, {
131127
payload: JSON.stringify(payload),
132128
options: {

0 commit comments

Comments
 (0)