Skip to content

Commit 2b4c668

Browse files
committed
refactor(execute): simplify async return (extracted from #4503)
1 parent 81e9219 commit 2b4c668

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

src/execution/execute.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,6 @@ async function completeAsyncIteratorValue(
947947
let containsPromise = false;
948948
const completedResults: Array<unknown> = [];
949949
let index = 0;
950-
const earlyReturn = asyncIterator.return?.bind(asyncIterator);
951950
try {
952951
while (true) {
953952
const itemPath = addPath(path, index, undefined);
@@ -996,12 +995,10 @@ async function completeAsyncIteratorValue(
996995
index++;
997996
}
998997
} catch (error) {
999-
if (earlyReturn !== undefined) {
1000-
earlyReturn().catch(() => {
1001-
/* c8 ignore next 1 */
1002-
// ignore error
1003-
});
1004-
}
998+
asyncIterator.return?.().catch(() => {
999+
/* c8 ignore next 1 */
1000+
// ignore error
1001+
});
10051002
throw error;
10061003
}
10071004
return containsPromise ? Promise.all(completedResults) : completedResults;

0 commit comments

Comments
 (0)