@@ -631,8 +631,9 @@ export function createIntegrationTestsSuite(
631631 } ) ;
632632
633633 // Cancellation test: start a long-running actor and cancel immediately, then verify it was aborted
634- it ( 'should abort actor run when request is cancelled' , async ( ) => {
635- const ACTOR_NAME = 'michal.kalita/test-timeout' ;
634+ // Is not possible to run this test in parallel
635+ it . runIf ( options . transport === 'streamable-http' ) ( 'should abort actor run on notifications/cancelled' , async ( ) => {
636+ const ACTOR_NAME = 'apify/rag-web-browser' ;
636637 const selectedToolName = actorNameToToolName ( ACTOR_NAME ) ;
637638 const client = await createClientFn ( { enableAddingActors : true } ) ;
638639
@@ -646,7 +647,7 @@ export function createIntegrationTestsSuite(
646647 method : 'tools/call' as const ,
647648 params : {
648649 name : selectedToolName ,
649- arguments : { timeout : 30 } ,
650+ arguments : { query : 'restaurants in San Francisco' , maxResults : 10 } ,
650651 } ,
651652 } , CallToolResultSchema , { signal : controller . signal } )
652653 // Ignores error "AbortError: This operation was aborted"
@@ -672,7 +673,52 @@ export function createIntegrationTestsSuite(
672673 return run . status === 'ABORTED' || run . status === 'ABORTING' ;
673674 }
674675 return false ;
675- } , { timeout : 30000 , interval : 1000 } ) ;
676+ } , { timeout : 3000 , interval : 500 } ) ;
677+ } ) ;
678+
679+ // Cancellation test using call-actor tool: start a long-running actor via call-actor and cancel immediately, then verify it was aborted
680+ it . runIf ( options . transport === 'streamable-http' ) ( 'should abort call-actor tool on notifications/cancelled' , async ( ) => {
681+ const ACTOR_NAME = 'apify/rag-web-browser' ;
682+ const client = await createClientFn ( { tools : [ 'actors' ] } ) ;
683+
684+ // Build request and cancel immediately via AbortController
685+ const controller = new AbortController ( ) ;
686+
687+ const requestPromise = client . request ( {
688+ method : 'tools/call' as const ,
689+ params : {
690+ name : HelperTools . ACTOR_CALL ,
691+ arguments : {
692+ actor : ACTOR_NAME ,
693+ step : 'call' ,
694+ input : { query : 'restaurants in San Francisco' , maxResults : 10 } ,
695+ } ,
696+ } ,
697+ } , CallToolResultSchema , { signal : controller . signal } )
698+ // Ignores error "AbortError: This operation was aborted"
699+ . catch ( ( ) => undefined ) ;
700+
701+ // Abort right away
702+ setTimeout ( ( ) => controller . abort ( ) , 1000 ) ;
703+
704+ // Ensure the request completes/cancels before proceeding
705+ await requestPromise ;
706+
707+ // Verify via Apify API that a recent run for this actor was aborted
708+ const api = new ApifyClient ( { token : process . env . APIFY_TOKEN as string } ) ;
709+ const actor = await api . actor ( ACTOR_NAME ) . get ( ) ;
710+ expect ( actor ) . toBeDefined ( ) ;
711+ const actId = actor ! . id as string ;
712+
713+ // Poll up to 30s for the latest run for this actor to reach ABORTED/ABORTING
714+ await vi . waitUntil ( async ( ) => {
715+ const runsList = await api . runs ( ) . list ( { limit : 5 , desc : true } ) ;
716+ const run = runsList . items . find ( ( r ) => r . actId === actId ) ;
717+ if ( run ) {
718+ return run . status === 'ABORTED' || run . status === 'ABORTING' ;
719+ }
720+ return false ;
721+ } , { timeout : 3000 , interval : 500 } ) ;
676722 } ) ;
677723
678724 // Environment variable tests - only applicable to stdio transport
0 commit comments