Skip to content

Commit 42a2535

Browse files
Track cleanup delete attempts in reconnect retry tests
Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent 63454ef commit 42a2535

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/ai/src/chatTransport.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ describe("TriggerChatTransport", function () {
663663
expect(firstReconnect).toBeNull();
664664
expect(secondReconnect).toBeNull();
665665
expect(fetchCalls).toBe(0);
666+
expect(runStore.deleteCallCount).toBe(2);
666667
expect(errors).toHaveLength(2);
667668
expect(errors[0]).toMatchObject({
668669
phase: "reconnect",
@@ -811,6 +812,7 @@ describe("TriggerChatTransport", function () {
811812
expect(firstReconnect).toBeNull();
812813
expect(secondReconnect).toBeNull();
813814
expect(fetchCalls).toBe(0);
815+
expect(runStore.deleteCallCount).toBe(2);
814816
expect(runStore.get("chat-inactive-delete-always-no-onerror")).toMatchObject({
815817
isActive: false,
816818
});
@@ -869,6 +871,7 @@ describe("TriggerChatTransport", function () {
869871

870872
expect(firstReconnect).toBeNull();
871873
expect(errors).toHaveLength(1);
874+
expect(runStore.deleteCallCount).toBe(1);
872875
expect(errors[0]).toMatchObject({
873876
phase: "reconnect",
874877
chatId: "chat-inactive-delete-string-retry",
@@ -884,6 +887,7 @@ describe("TriggerChatTransport", function () {
884887

885888
expect(secondReconnect).toBeNull();
886889
expect(errors).toHaveLength(1);
890+
expect(runStore.deleteCallCount).toBe(2);
887891
expect(runStore.get("chat-inactive-delete-string-retry")).toBeUndefined();
888892
});
889893

@@ -3934,15 +3938,15 @@ class FailingCleanupDeleteRunStore extends InMemoryTriggerChatRunStore {
39343938
}
39353939

39363940
class FailingCleanupDeleteValueRunStore extends InMemoryTriggerChatRunStore {
3937-
private deleteCalls = 0;
3941+
public deleteCallCount = 0;
39383942

39393943
constructor(private readonly thrownValue: unknown) {
39403944
super();
39413945
}
39423946

39433947
public delete(chatId: string): void {
3944-
this.deleteCalls += 1;
3945-
if (this.deleteCalls === 1) {
3948+
this.deleteCallCount += 1;
3949+
if (this.deleteCallCount === 1) {
39463950
throw this.thrownValue;
39473951
}
39483952

@@ -3951,7 +3955,10 @@ class FailingCleanupDeleteValueRunStore extends InMemoryTriggerChatRunStore {
39513955
}
39523956

39533957
class AlwaysFailCleanupDeleteRunStore extends InMemoryTriggerChatRunStore {
3958+
public deleteCallCount = 0;
3959+
39543960
public delete(_chatId: string): void {
3961+
this.deleteCallCount += 1;
39553962
throw new Error("cleanup delete always fails");
39563963
}
39573964
}

0 commit comments

Comments
 (0)