@@ -4725,7 +4725,7 @@ describe("Cline", () => {
47254725 expect ( abortSpy ) . toHaveBeenCalled ( )
47264726
47274727 // Verify the controller was cleared
4728- expect ( task . currentRequestAbortController ) . toBeUndefined ( )
4728+ expect ( task [ " currentRequestAbortController" ] ) . toBeUndefined ( )
47294729
47304730 // Verify logging
47314731 expect ( consoleLogSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( "Aborting current HTTP request" ) )
@@ -5036,6 +5036,7 @@ describe("Cline", () => {
50365036 "function" in tool ? [ tool . function . name ] : [ ] ,
50375037 )
50385038 expect ( names . filter ( ( name ) => name . startsWith ( "mcp--" ) ) ) . toHaveLength ( expected )
5039+ if ( historyCall ) expect ( names ) . toContain ( "mcp--catalog--tool_99" )
50395040 expect ( names ) . toContain ( "read_file" )
50405041 expect ( names ) . not . toContain ( "mcp_load" )
50415042 if ( provider === providerIdentifiers . gemini )
@@ -5045,6 +5046,51 @@ describe("Cline", () => {
50455046 } ,
50465047 )
50475048
5049+ it . each ( [ "abort" , "abandoned" ] as const ) (
5050+ "stops a request canceled during tool building: %s" ,
5051+ async ( flag ) => {
5052+ const task = new Task ( {
5053+ provider : mockProvider ,
5054+ apiConfiguration : mockApiConfig ,
5055+ task : "search tickets" ,
5056+ startTask : false ,
5057+ } )
5058+ vi . spyOn ( getTaskTestAccess ( task ) , "getSystemPrompt" ) . mockResolvedValue ( "mock prompt" )
5059+ vi . spyOn ( task . api , "getModel" ) . mockReturnValue ( {
5060+ id : "test-model" ,
5061+ info : { contextWindow : 200000 , maxTokens : 4096 , supportsPromptCache : false } ,
5062+ } )
5063+ const createMessage = vi . spyOn ( task . api , "createMessage" )
5064+ let release = ( ) => { }
5065+ const gate = new Promise < void > ( ( resolve ) => {
5066+ release = resolve
5067+ } )
5068+ let entered = ( ) => { }
5069+ const building = new Promise < void > ( ( resolve ) => {
5070+ entered = resolve
5071+ } )
5072+ const build = vi
5073+ . spyOn ( buildTools , "buildNativeToolsArrayWithRestrictions" )
5074+ . mockImplementation ( async ( ) => {
5075+ entered ( )
5076+ await gate
5077+ return { tools : [ ] }
5078+ } )
5079+ try {
5080+ const request = task . attemptApiRequest ( 0 ) . next ( )
5081+ await building
5082+ task [ flag ] = true
5083+ release ( )
5084+ await expect ( request ) . rejects . toThrow ( "aborted during request construction" )
5085+ expect ( createMessage ) . not . toHaveBeenCalled ( )
5086+ expect ( task [ "currentRequestAbortController" ] ) . toBeUndefined ( )
5087+ } finally {
5088+ release ( )
5089+ build . mockRestore ( )
5090+ }
5091+ } ,
5092+ )
5093+
50485094 it . each ( [ "manual" , "recovery" , "automatic" ] as const ) (
50495095 "passes task routing settings to the %s condensation build" ,
50505096 async ( path ) => {
@@ -5121,7 +5167,7 @@ describe("Cline", () => {
51215167 task . cancelCurrentRequest ( )
51225168
51235169 expect ( abortSpy ) . toHaveBeenCalledTimes ( 1 )
5124- expect ( task . currentRequestAbortController ) . toBeUndefined ( )
5170+ expect ( task [ " currentRequestAbortController" ] ) . toBeUndefined ( )
51255171 } )
51265172
51275173 it ( "should reject streaming consumption when aborted between chunks" , async ( ) => {
@@ -5330,7 +5376,7 @@ describe("Cline", () => {
53305376 } ,
53315377 ]
53325378
5333- expect ( task . currentRequestAbortController ) . toBeUndefined ( )
5379+ expect ( task [ " currentRequestAbortController" ] ) . toBeUndefined ( )
53345380
53355381 const iterator = task . attemptApiRequest ( 0 )
53365382 await iterator . next ( )
@@ -6066,7 +6112,7 @@ describe("Cline", () => {
60666112 expect ( createMessageSpy ) . not . toHaveBeenCalled ( )
60676113 // The per-request controller is only created once the request is
60686114 // committed, so a cancelled construction never reaches it.
6069- expect ( task . currentRequestAbortController ) . toBeUndefined ( )
6115+ expect ( task [ " currentRequestAbortController" ] ) . toBeUndefined ( )
60706116 await cancelling
60716117 } finally {
60726118 vi . useRealTimers ( )
@@ -6126,7 +6172,7 @@ describe("Cline", () => {
61266172 expect ( createMessageSpy ) . not . toHaveBeenCalled ( )
61276173 // The per-request controller is only created once the request is
61286174 // committed, so a disposed construction never reaches it.
6129- expect ( task . currentRequestAbortController ) . toBeUndefined ( )
6175+ expect ( task [ " currentRequestAbortController" ] ) . toBeUndefined ( )
61306176 await disposal
61316177 } finally {
61326178 vi . useRealTimers ( )
0 commit comments