Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2655,19 +2655,7 @@ function buildSyncStreamItemQueue(

let iteration = iterator.next();
let currentIndex = initialIndex + 1;
let currentStreamItem:
| BoxedPromiseOrValue<StreamItemResult>
| (() => BoxedPromiseOrValue<StreamItemResult>) = firstStreamItem;
while (!iteration.done) {
// TODO: add test case for early sync termination
/* c8 ignore next 6 */
if (currentStreamItem instanceof BoxedPromiseOrValue) {
const result = currentStreamItem.value;
if (!isPromise(result) && result.item === undefined) {
break;
}
}

const itemPath = addPath(streamPath, currentIndex, undefined);

const value = iteration.value;
Expand All @@ -2683,11 +2671,18 @@ function buildSyncStreamItemQueue(
itemType,
);

currentStreamItem = enableEarlyExecution
? new BoxedPromiseOrValue(currentExecutor())
: () => new BoxedPromiseOrValue(currentExecutor());

streamItemQueue.push(currentStreamItem);
if (enableEarlyExecution) {
const currentStreamItem = new BoxedPromiseOrValue(currentExecutor());
const result = currentStreamItem.value;
streamItemQueue.push(currentStreamItem);
// TODO: add test case for early sync termination
/* c8 ignore next 3 */
if (!isPromise(result) && result.item === undefined) {
break;
}
} else {
streamItemQueue.push(() => new BoxedPromiseOrValue(currentExecutor()));
}

iteration = iterator.next();
currentIndex = initialIndex + 1;
Expand Down
Loading