@@ -394,6 +394,82 @@ describe("Cline", () => {
394394 new Task ( { provider : mockProvider , apiConfiguration : mockApiConfig } )
395395 } ) . toThrow ( "Either historyItem or task/images must be provided" )
396396 } )
397+
398+ it ( "should ignore cancelled background resumeTaskFromHistory errors" , async ( ) => {
399+ const resumeSpy = vi
400+ . spyOn ( Task . prototype as any , "resumeTaskFromHistory" )
401+ . mockImplementationOnce ( async function ( this : Task ) {
402+ this . abort = true
403+ throw new Error ( "resume aborted" )
404+ } )
405+ const consoleErrorSpy = vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => { } )
406+
407+ new Task ( {
408+ provider : mockProvider ,
409+ apiConfiguration : mockApiConfig ,
410+ historyItem : {
411+ id : "history-task-id" ,
412+ number : 1 ,
413+ ts : Date . now ( ) ,
414+ task : "historical task" ,
415+ tokensIn : 0 ,
416+ tokensOut : 0 ,
417+ cacheWrites : 0 ,
418+ cacheReads : 0 ,
419+ totalCost : 0 ,
420+ } as any ,
421+ startTask : true ,
422+ } )
423+
424+ await Promise . resolve ( )
425+ await Promise . resolve ( )
426+
427+ const lifecycleErrors = consoleErrorSpy . mock . calls . filter (
428+ ( [ message ] ) => typeof message === "string" && message . includes ( "[Task#resumeTaskFromHistory]" ) ,
429+ )
430+ expect ( lifecycleErrors ) . toHaveLength ( 0 )
431+
432+ resumeSpy . mockRestore ( )
433+ consoleErrorSpy . mockRestore ( )
434+ } )
435+
436+ it ( "should log unexpected background resumeTaskFromHistory errors" , async ( ) => {
437+ const resumeSpy = vi
438+ . spyOn ( Task . prototype as any , "resumeTaskFromHistory" )
439+ . mockRejectedValueOnce ( new Error ( "unexpected resume failure" ) )
440+ const consoleErrorSpy = vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => { } )
441+
442+ new Task ( {
443+ provider : mockProvider ,
444+ apiConfiguration : mockApiConfig ,
445+ historyItem : {
446+ id : "history-task-id" ,
447+ number : 1 ,
448+ ts : Date . now ( ) ,
449+ task : "historical task" ,
450+ tokensIn : 0 ,
451+ tokensOut : 0 ,
452+ cacheWrites : 0 ,
453+ cacheReads : 0 ,
454+ totalCost : 0 ,
455+ } as any ,
456+ startTask : true ,
457+ } )
458+
459+ await Promise . resolve ( )
460+ await Promise . resolve ( )
461+
462+ const lifecycleErrors = consoleErrorSpy . mock . calls . filter (
463+ ( [ message ] ) =>
464+ typeof message === "string" &&
465+ message . includes ( "[Task#resumeTaskFromHistory]" ) &&
466+ message . includes ( "unexpected resume failure" ) ,
467+ )
468+ expect ( lifecycleErrors ) . toHaveLength ( 1 )
469+
470+ resumeSpy . mockRestore ( )
471+ consoleErrorSpy . mockRestore ( )
472+ } )
397473 } )
398474
399475 describe ( "getEnvironmentDetails" , ( ) => {
0 commit comments