@@ -2655,19 +2655,7 @@ function buildSyncStreamItemQueue(
26552655
26562656 let iteration = iterator . next ( ) ;
26572657 let currentIndex = initialIndex + 1 ;
2658- let currentStreamItem :
2659- | BoxedPromiseOrValue < StreamItemResult >
2660- | ( ( ) => BoxedPromiseOrValue < StreamItemResult > ) = firstStreamItem ;
26612658 while ( ! iteration . done ) {
2662- // TODO: add test case for early sync termination
2663- /* c8 ignore next 6 */
2664- if ( currentStreamItem instanceof BoxedPromiseOrValue ) {
2665- const result = currentStreamItem . value ;
2666- if ( ! isPromise ( result ) && result . item === undefined ) {
2667- break ;
2668- }
2669- }
2670-
26712659 const itemPath = addPath ( streamPath , currentIndex , undefined ) ;
26722660
26732661 const value = iteration . value ;
@@ -2683,11 +2671,18 @@ function buildSyncStreamItemQueue(
26832671 itemType ,
26842672 ) ;
26852673
2686- currentStreamItem = enableEarlyExecution
2687- ? new BoxedPromiseOrValue ( currentExecutor ( ) )
2688- : ( ) => new BoxedPromiseOrValue ( currentExecutor ( ) ) ;
2689-
2690- streamItemQueue . push ( currentStreamItem ) ;
2674+ if ( enableEarlyExecution ) {
2675+ const currentStreamItem = new BoxedPromiseOrValue ( currentExecutor ( ) ) ;
2676+ const result = currentStreamItem . value ;
2677+ streamItemQueue . push ( currentStreamItem ) ;
2678+ // TODO: add test case for early sync termination
2679+ /* c8 ignore next 3 */
2680+ if ( ! isPromise ( result ) && result . item === undefined ) {
2681+ break ;
2682+ }
2683+ } else {
2684+ streamItemQueue . push ( ( ) => new BoxedPromiseOrValue ( currentExecutor ( ) ) ) ;
2685+ }
26912686
26922687 iteration = iterator . next ( ) ;
26932688 currentIndex = initialIndex + 1 ;
0 commit comments