Skip to content

Commit fe5cd3d

Browse files
Use immutable run-state updates in tracking and cleanup paths
Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent e97fc5c commit fe5cd3d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/ai/src/chatTransport.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,10 @@ export class TriggerChatTransport<
337337
return;
338338
}
339339

340-
runState.lastEventId = part.id;
341-
await this.runStore.set(runState);
340+
await this.runStore.set({
341+
...runState,
342+
lastEventId: part.id,
343+
});
342344
}
343345

344346
const runState = await this.runStore.get(chatId);
@@ -380,8 +382,10 @@ export class TriggerChatTransport<
380382
}
381383

382384
private async markRunInactiveAndDelete(runState: TriggerChatRunState) {
383-
runState.isActive = false;
384-
await this.runStore.set(runState);
385+
await this.runStore.set({
386+
...runState,
387+
isActive: false,
388+
});
385389
await this.runStore.delete(runState.chatId);
386390
}
387391

0 commit comments

Comments
 (0)