@@ -310,14 +310,18 @@ export class IncrementalExecutor<
310310 this . streams = [ ] ;
311311 }
312312
313- createSubExecutor (
313+ getCreateSubExecutor ( ) : (
314314 deferUsageSet ?: DeferUsageSet ,
315- ) : IncrementalExecutor < TExperimental > {
316- return new IncrementalExecutor (
317- this . validatedExecutionArgs ,
318- this . sharedExecutionContext ,
319- deferUsageSet ,
320- ) ;
315+ ) => IncrementalExecutor < TExperimental > {
316+ const validatedExecutionArgs = this . validatedExecutionArgs ;
317+ const sharedExecutionContext = this . sharedExecutionContext ;
318+
319+ return ( deferUsageSet ?: DeferUsageSet ) =>
320+ new IncrementalExecutor < TExperimental > (
321+ validatedExecutionArgs ,
322+ sharedExecutionContext ,
323+ deferUsageSet ,
324+ ) ;
321325 }
322326
323327 override abort ( reason ?: unknown ) : void {
@@ -354,7 +358,7 @@ export class IncrementalExecutor<
354358 errors ,
355359 work ,
356360 this . validatedExecutionArgs . externalAbortSignal ,
357- ( ) => this . finishSharedExecution ( ) ,
361+ this . getFinishSharedExecution ( ) ,
358362 ) as TExperimental ;
359363 }
360364
@@ -490,10 +494,11 @@ export class IncrementalExecutor<
490494 newGroupedFieldSets : Map < DeferUsageSet , GroupedFieldSet > ,
491495 deliveryGroupMap : ReadonlyMap < DeferUsage , DeliveryGroup > ,
492496 ) : void {
497+ const createSubExecutor = this . getCreateSubExecutor ( ) ;
493498 for ( const [ deferUsageSet , groupedFieldSet ] of newGroupedFieldSets ) {
494499 const deliveryGroups = getDeliveryGroups ( deferUsageSet , deliveryGroupMap ) ;
495500
496- const executor = this . createSubExecutor ( deferUsageSet ) ;
501+ const executor = createSubExecutor ( deferUsageSet ) ;
497502
498503 const executionGroup : ExecutionGroup = {
499504 groups : deliveryGroups ,
@@ -721,7 +726,9 @@ export class IncrementalExecutor<
721726 itemType : GraphQLOutputType ,
722727 isAsync : boolean | undefined ,
723728 ) : Queue < StreamItemResult > {
729+ const createSubExecutor = this . getCreateSubExecutor ( ) ;
724730 const { enableEarlyExecution } = this . validatedExecutionArgs ;
731+ const sharedExecutionContext = this . sharedExecutionContext ;
725732 const queue = new Queue < StreamItemResult > (
726733 async ( { push, stop, onStop, started } ) => {
727734 const abortStreamItems = new Set < ( reason ?: unknown ) => void > ( ) ;
@@ -735,13 +742,13 @@ export class IncrementalExecutor<
735742 abortStreamItem ( reason ) ;
736743 }
737744 if ( isAsync ) {
738- this . sharedExecutionContext . asyncWorkTracker . add (
745+ sharedExecutionContext . asyncWorkTracker . add (
739746 returnIteratorCatchingErrors (
740747 iterator as AsyncIterator < unknown > ,
741748 ) ,
742749 ) ;
743750 } else {
744- this . sharedExecutionContext . asyncWorkTracker . addValues (
751+ sharedExecutionContext . asyncWorkTracker . addValues (
745752 collectIteratorPromises ( iterator as Iterator < unknown > ) ,
746753 ) ;
747754 }
@@ -785,7 +792,7 @@ export class IncrementalExecutor<
785792
786793 const itemPath = addPath ( streamPath , index , undefined ) ;
787794
788- const executor = this . createSubExecutor ( ) ;
795+ const executor = createSubExecutor ( ) ;
789796
790797 let streamItemResult = executor . completeStreamItem (
791798 itemPath ,
0 commit comments