@@ -60,6 +60,13 @@ const checkpointDeleteRequests = new Counter({
6060 registers : [ register ] ,
6161} ) ;
6262
63+ const checkpointCancelRequests = new Counter ( {
64+ name : "checkpoint_cancel_requests_total" ,
65+ help : "Checkpoint cancel requests attempted when a run continues, by outcome" ,
66+ labelNames : [ "result" ] , // "sent" | "no_client" | "not_applicable" | "http_error"
67+ registers : [ register ] ,
68+ } ) ;
69+
6370const WorkloadActionParams = z . object ( {
6471 runFriendlyId : z . string ( ) ,
6572 snapshotFriendlyId : z . string ( ) ,
@@ -283,6 +290,35 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
283290 checkpointDeleteRequests . inc ( { result : "sent" } ) ;
284291 }
285292
293+ /**
294+ * cancelCheckpoints tells the checkpoint service a resumed run's in-flight checkpoint is moot.
295+ * Must be called after the reply is sent: it never delays the runner. Without it the checkpoint
296+ * is abandoned by a periodic snapshot poll instead, up to that interval later.
297+ */
298+ private async cancelCheckpoints ( runFriendlyId : string ) : Promise < void > {
299+ if ( ! this . checkpointClient ) {
300+ checkpointCancelRequests . inc ( { result : "no_client" } ) ;
301+ return ;
302+ }
303+
304+ if ( this . snapshotService ) {
305+ checkpointCancelRequests . inc ( { result : "not_applicable" } ) ;
306+ return ;
307+ }
308+
309+ const [ error , accepted ] = await tryCatch (
310+ this . checkpointClient . cancelCheckpoints ( { runFriendlyId } )
311+ ) ;
312+
313+ if ( error || ! accepted ) {
314+ checkpointCancelRequests . inc ( { result : "http_error" } ) ;
315+ this . logger . error ( "Failed to request checkpoint cancel" , { runFriendlyId, error } ) ;
316+ return ;
317+ }
318+
319+ checkpointCancelRequests . inc ( { result : "sent" } ) ;
320+ }
321+
286322 /**
287323 * Sets common route meta on the wide-event state from URL params.
288324 */
@@ -643,6 +679,8 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
643679 }
644680
645681 reply . json ( continuationResult . data as WorkloadContinueRunExecutionResponseBody ) ;
682+
683+ await this . cancelCheckpoints ( params . runFriendlyId ) ;
646684 }
647685 ) ,
648686 }
0 commit comments