Skip to content

Commit e9f45f0

Browse files
committed
fix(task): apply first-reason-wins to both abort paths in catch block
1 parent 62b822f commit e9f45f0

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/core/task/Task.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3751,8 +3751,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
37513751
console.log(
37523752
`[Task#${this.taskId}.${this.instanceId}] Task aborted during mid-stream retry backoff`,
37533753
)
3754-
// Abort the entire task
3755-
this.abortReason = "user_cancelled"
3754+
this.abortReason ??= "user_cancelled"
37563755
await this.abortTask()
37573756
break
37583757
}

‎src/core/task/__tests__/Task.abort-reason-race.spec.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function makeMockProvider() {
120120
}
121121
}
122122

123-
describe("Task abort-reason race (RSK-19 regression)", () => {
123+
describe("Task abort-reason race", () => {
124124
let mockApiConfig: ProviderSettings
125125

126126
beforeEach(() => {
@@ -173,6 +173,7 @@ describe("Task abort-reason race (RSK-19 regression)", () => {
173173
// The outer catch in recursivelyMakeClineRequests swallows the abort throw and returns true.
174174
const result = await task.recursivelyMakeClineRequests([{ type: "text", text: "help me" }])
175175
expect(result).toBe(true)
176+
expect(task.didFinishAbortingStream).toBe(true)
176177
expect(abortTaskSpy).toHaveBeenCalledOnce()
177178
expect(task.abortReason).toBe("user_cancelled")
178179
})

‎src/core/webview/__tests__/ClineProvider.taskHistory.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ describe("ClineProvider Task History Synchronization", () => {
961961
expect(logSpy).toHaveBeenCalledWith(expect.stringContaining("[onTaskCompleted] Failed to write"))
962962
})
963963

964-
it("onTaskAborted does not call createTaskWithHistoryItem (RSK-19 guard)", async () => {
964+
it("onTaskAborted does not call createTaskWithHistoryItem", async () => {
965965
// Store the item so getTaskWithId succeeds: without it, the old branch's catch
966966
// swallows the error and the test passes even if the branch comes back.
967967
const existing = createHistoryItem({ id: "task-abort-1", task: "T" })

0 commit comments

Comments
 (0)