@@ -321,10 +321,10 @@ export class IncrementalExecutor<
321321 override cancel ( reason ?: unknown ) : void {
322322 super . cancel ( reason ) ;
323323 for ( const task of this . tasks ) {
324- task . computation . cancel ( ) ;
324+ task . computation . cancel ( reason ) ;
325325 }
326326 for ( const stream of this . streams ) {
327- stream . queue . abort ( ) ;
327+ stream . queue . abort ( reason ) ;
328328 }
329329 }
330330
@@ -503,7 +503,7 @@ export class IncrementalExecutor<
503503 groupedFieldSet ,
504504 deliveryGroupMap ,
505505 ) ,
506- ( ) => executor . cancel ( ) ,
506+ ( reason ) => executor . cancel ( reason ) ,
507507 ) ,
508508 } ;
509509
@@ -581,10 +581,14 @@ export class IncrementalExecutor<
581581 return { groups, tasks, streams } ;
582582 }
583583
584+ const cancellationReason = new Error (
585+ 'Cancelled secondary to null within original result' ,
586+ ) ;
587+
584588 const filteredTasks : Array < ExecutionGroup > = [ ] ;
585589 for ( const task of tasks ) {
586590 if ( collectedErrors . hasNulledPosition ( task . path ) ) {
587- task . computation . cancel ( ) ;
591+ task . computation . cancel ( cancellationReason ) ;
588592 } else {
589593 filteredTasks . push ( task ) ;
590594 }
@@ -593,7 +597,7 @@ export class IncrementalExecutor<
593597 const filteredStreams : Array < ItemStream > = [ ] ;
594598 for ( const stream of streams ) {
595599 if ( collectedErrors . hasNulledPosition ( stream . path ) ) {
596- stream . queue . cancel ( ) ;
600+ stream . queue . abort ( cancellationReason ) ;
597601 } else {
598602 filteredStreams . push ( stream ) ;
599603 }
@@ -713,11 +717,13 @@ export class IncrementalExecutor<
713717 const { enableEarlyExecution } = this . validatedExecutionArgs ;
714718 const queue = new Queue < StreamItemResult > (
715719 async ( { push, stop, started, stopped } ) => {
716- const cancelStreamItems = new Set < ( ) => void > ( ) ;
720+ const cancelStreamItems = new Set < ( reason ?: unknown ) => void > ( ) ;
717721
718722 // eslint-disable-next-line @typescript-eslint/no-floating-promises
719- stopped . then ( ( ) => {
720- cancelStreamItems . forEach ( ( cancelStreamItem ) => cancelStreamItem ( ) ) ;
723+ stopped . then ( ( reason ) => {
724+ cancelStreamItems . forEach ( ( cancelStreamItem ) =>
725+ cancelStreamItem ( reason ) ,
726+ ) ;
721727 returnIteratorCatchingErrors ( iterator ) ;
722728 } ) ;
723729 await ( enableEarlyExecution ? Promise . resolve ( ) : started ) ;
@@ -763,7 +769,8 @@ export class IncrementalExecutor<
763769 ) ;
764770 if ( isPromise ( streamItemResult ) ) {
765771 if ( enableEarlyExecution ) {
766- const cancelStreamItem = ( ) => executor . cancel ( ) ;
772+ const cancelStreamItem = ( reason ?: unknown ) =>
773+ executor . cancel ( reason ) ;
767774 cancelStreamItems . add ( cancelStreamItem ) ;
768775 streamItemResult = streamItemResult . finally ( ( ) => {
769776 cancelStreamItems . delete ( cancelStreamItem ) ;
0 commit comments