Skip to content

Commit 85268aa

Browse files
committed
remove some extra code
1 parent 0bd49d7 commit 85268aa

File tree

2 files changed

+13
-57
lines changed

2 files changed

+13
-57
lines changed

src/core/checkpoints/__tests__/checkpoint.test.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,6 @@ describe("Checkpoint functionality", () => {
176176
expect(mockTask.enableCheckpoints).toBe(true)
177177
})
178178

179-
it("should prevent duplicate checkpoint operations for the same task", async () => {
180-
// Start two checkpoint saves simultaneously
181-
const promise1 = checkpointSave(mockTask)
182-
const promise2 = checkpointSave(mockTask)
183-
184-
// Wait for both promises
185-
const [result1, result2] = await Promise.all([promise1, promise2])
186-
187-
// Both should return the same result
188-
expect(result1).toEqual(result2)
189-
190-
// saveCheckpoint should only be called once due to deduplication
191-
expect(mockCheckpointService.saveCheckpoint).toHaveBeenCalledTimes(1)
192-
})
193-
194179
it("should handle errors gracefully and disable checkpoints", async () => {
195180
mockCheckpointService.saveCheckpoint.mockRejectedValue(new Error("Save failed"))
196181

src/core/checkpoints/index.ts

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ import { DIFF_VIEW_URI_SCHEME } from "../../integrations/editor/DiffViewProvider
1616

1717
import { CheckpointServiceOptions, RepoPerTaskCheckpointService } from "../../services/checkpoints"
1818

19-
// Map to store pending checkpoint operations by taskId to prevent race conditions
20-
const pendingCheckpointOperations = new Map<string, Promise<any>>()
21-
2219
export function getCheckpointService(cline: Task) {
2320
if (!cline.enableCheckpoints) {
2421
return undefined
@@ -195,49 +192,23 @@ async function getInitializedCheckpointService(
195192
}
196193

197194
export async function checkpointSave(cline: Task, force = false) {
198-
const taskId = cline.taskId
199-
200-
// Check if there's already a pending checkpoint operation for this task
201-
const existingOperation = pendingCheckpointOperations.get(taskId)
202-
if (existingOperation) {
203-
// Return the existing Promise to prevent duplicate operations
204-
return existingOperation
205-
}
206-
207-
// Create a new checkpoint operation Promise
208-
const checkpointOperation = (async () => {
209-
try {
210-
// Use getInitializedCheckpointService to wait for initialization
211-
const service = await getInitializedCheckpointService(cline)
212-
213-
if (!service) {
214-
return
215-
}
216-
217-
TelemetryService.instance.captureCheckpointCreated(cline.taskId)
195+
try {
196+
// Use getInitializedCheckpointService to wait for initialization
197+
const service = await getInitializedCheckpointService(cline)
218198

219-
// Start the checkpoint process in the background.
220-
return await service.saveCheckpoint(`Task: ${cline.taskId}, Time: ${Date.now()}`, { allowEmpty: force })
221-
} catch (err) {
222-
console.error("[Task#checkpointSave] caught unexpected error, disabling checkpoints", err)
223-
cline.enableCheckpoints = false
224-
return undefined
199+
if (!service) {
200+
return
225201
}
226-
})()
227202

228-
// Store the operation in the Map
229-
pendingCheckpointOperations.set(taskId, checkpointOperation)
230-
231-
// Clean up the Map entry after the operation completes (success or failure)
232-
checkpointOperation
233-
.finally(() => {
234-
pendingCheckpointOperations.delete(taskId)
235-
})
236-
.catch(() => {
237-
// Error already handled above, this catch prevents unhandled rejection
238-
})
203+
TelemetryService.instance.captureCheckpointCreated(cline.taskId)
239204

240-
return checkpointOperation
205+
// Start the checkpoint process in the background.
206+
return await service.saveCheckpoint(`Task: ${cline.taskId}, Time: ${Date.now()}`, { allowEmpty: force })
207+
} catch (err) {
208+
console.error("[Task#checkpointSave] caught unexpected error, disabling checkpoints", err)
209+
cline.enableCheckpoints = false
210+
return undefined
211+
}
241212
}
242213

243214
export type CheckpointRestoreOptions = {

0 commit comments

Comments
 (0)