Skip to content

Commit 7e0eb51

Browse files
Extract inactive reconnect cleanup into dedicated helper
Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent 42a2535 commit 7e0eb51

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

packages/ai/src/chatTransport.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,7 @@ export class TriggerChatTransport<
258258
}
259259

260260
if (!runState.isActive) {
261-
try {
262-
await this.runStore.delete(options.chatId);
263-
} catch (error) {
264-
await this.reportError({
265-
phase: "reconnect",
266-
chatId: runState.chatId,
267-
runId: runState.runId,
268-
error: normalizeError(error),
269-
});
270-
}
261+
await this.cleanupInactiveReconnectState(runState);
271262
return null;
272263
}
273264

@@ -423,6 +414,19 @@ export class TriggerChatTransport<
423414
}
424415
}
425416

417+
private async cleanupInactiveReconnectState(runState: TriggerChatRunState) {
418+
try {
419+
await this.runStore.delete(runState.chatId);
420+
} catch (error) {
421+
await this.reportError({
422+
phase: "reconnect",
423+
chatId: runState.chatId,
424+
runId: runState.runId,
425+
error: normalizeError(error),
426+
});
427+
}
428+
}
429+
426430
private async reportError(event: TriggerChatTransportError) {
427431
if (!this.onError) {
428432
return;

0 commit comments

Comments
 (0)