@@ -16,9 +16,6 @@ import { DIFF_VIEW_URI_SCHEME } from "../../integrations/editor/DiffViewProvider
1616
1717import { 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-
2219export function getCheckpointService ( cline : Task ) {
2320 if ( ! cline . enableCheckpoints ) {
2421 return undefined
@@ -195,49 +192,23 @@ async function getInitializedCheckpointService(
195192}
196193
197194export 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
243214export type CheckpointRestoreOptions = {
0 commit comments