Merge pull request #3912 from code-yeongyu/fix/sync-poller-abort-handling

fix(delegate-task): handle abort race in sync session polling
This commit is contained in:
YeonGyu-Kim
2026-05-11 09:22:35 +09:00
committed by GitHub
8 changed files with 634 additions and 19 deletions
@@ -421,6 +421,37 @@ describe("pollSyncSession", () => {
expect(result).toContain("ses_abort")
expect(abortCount).toBe(1)
})
test("retries final message fetch on abort before returning aborted", async () => {
// given: abort signal set and message fetch keeps failing
const { pollSyncSession } = require("./sync-session-poller")
let abortCount = 0
let messageCallCount = 0
const mockClient = {
session: {
abort: async () => {
abortCount++
},
messages: async () => {
messageCallCount++
throw new Error("temporary fetch failure")
},
status: async () => ({ data: {} }),
},
}
const result = await pollSyncSession(createMockCtx(true), mockClient, {
sessionID: "ses_abort_retry",
agentToUse: "test-agent",
toastManager: { removeTask: () => {} },
taskId: "task_123",
})
// then
expect(result).toContain("Task aborted")
expect(messageCallCount).toBe(3)
expect(abortCount).toBe(1)
})
})
describe("timeout handling", () => {