Skip to content

Commit d27b5d4

Browse files
committed
refactor(execute): simplify async return
extracted from #4503
1 parent 6391039 commit d27b5d4

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/execution/execute.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,6 @@ async function completeAsyncIteratorValue(
908908
let containsPromise = false;
909909
const completedResults: Array<unknown> = [];
910910
let index = 0;
911-
const earlyReturn = asyncIterator.return?.bind(asyncIterator);
912911
try {
913912
while (true) {
914913
const itemPath = addPath(path, index, undefined);
@@ -965,12 +964,10 @@ async function completeAsyncIteratorValue(
965964
index++;
966965
}
967966
} catch (error) {
968-
if (earlyReturn !== undefined) {
969-
earlyReturn().catch(() => {
970-
/* c8 ignore next 1 */
971-
// ignore error
972-
});
973-
}
967+
asyncIterator.return?.().catch(() => {
968+
/* c8 ignore next 1 */
969+
// ignore error
970+
});
974971
throw error;
975972
}
976973
return containsPromise ? Promise.all(completedResults) : completedResults;

0 commit comments

Comments
 (0)