Retry inactive reconnect cleanup after string delete failures

Co-authored-by: Eric Allam <eric@trigger.dev>
This commit is contained in:
Cursor Agent
2026-02-15 02:52:44 +00:00
parent 3732bd6096
commit 2b6723e41c
+49 -1
View File
@@ -706,6 +706,52 @@ describe("TriggerChatTransport", function () {
expect(stream).toBeNull();
});
it("retries inactive reconnect string cleanup on subsequent reconnect attempts", async function () {
const errors: TriggerChatTransportError[] = [];
const runStore = new FailingCleanupDeleteValueRunStore("cleanup delete string failure");
runStore.set({
chatId: "chat-inactive-delete-string-retry",
runId: "run_inactive_delete_string_retry",
publicAccessToken: "pk_inactive_delete_string_retry",
streamKey: "chat-stream",
lastEventId: "10-0",
isActive: false,
});
const transport = new TriggerChatTransport({
task: "chat-task",
stream: "chat-stream",
accessToken: "pk_trigger",
runStore,
onError: function onError(error) {
errors.push(error);
},
});
const firstReconnect = await transport.reconnectToStream({
chatId: "chat-inactive-delete-string-retry",
});
expect(firstReconnect).toBeNull();
expect(errors).toHaveLength(1);
expect(errors[0]).toMatchObject({
phase: "reconnect",
chatId: "chat-inactive-delete-string-retry",
runId: "run_inactive_delete_string_retry",
});
expect(runStore.get("chat-inactive-delete-string-retry")).toMatchObject({
isActive: false,
});
const secondReconnect = await transport.reconnectToStream({
chatId: "chat-inactive-delete-string-retry",
});
expect(secondReconnect).toBeNull();
expect(errors).toHaveLength(1);
expect(runStore.get("chat-inactive-delete-string-retry")).toBeUndefined();
});
it("normalizes non-Error inactive reconnect cleanup delete failures through onError", async function () {
const errors: TriggerChatTransportError[] = [];
const runStore = new FailingCleanupDeleteValueRunStore("cleanup delete string failure");
@@ -3624,11 +3670,13 @@ class FailingCleanupDeleteValueRunStore extends InMemoryTriggerChatRunStore {
super();
}
public delete(_chatId: string): void {
public delete(chatId: string): void {
this.deleteCalls += 1;
if (this.deleteCalls === 1) {
throw this.thrownValue;
}
super.delete(chatId);
}
}