Skip to content

Commit a8d1201

Browse files
committed
refactor(execute): simplify async return
extracted from graphql#4503
1 parent d56a2f6 commit a8d1201

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
@@ -907,7 +907,6 @@ async function completeAsyncIteratorValue(
907907
let containsPromise = false;
908908
const completedResults: Array<unknown> = [];
909909
let index = 0;
910-
const earlyReturn = asyncIterator.return?.bind(asyncIterator);
911910
try {
912911
while (true) {
913912
const itemPath = addPath(path, index, undefined);
@@ -964,12 +963,10 @@ async function completeAsyncIteratorValue(
964963
index++;
965964
}
966965
} catch (error) {
967-
if (earlyReturn !== undefined) {
968-
earlyReturn().catch(() => {
969-
/* c8 ignore next 1 */
970-
// ignore error
971-
});
972-
}
966+
asyncIterator.return?.().catch(() => {
967+
/* c8 ignore next 1 */
968+
// ignore error
969+
});
973970
throw error;
974971
}
975972
return containsPromise ? Promise.all(completedResults) : completedResults;

0 commit comments

Comments
 (0)