Skip to content

Commit

Permalink
Update ongoing promise in async iterator return() method
Browse files Browse the repository at this point in the history
Fixes #268.
  • Loading branch information
MattiasBuelens authored Feb 13, 2024
1 parent da99c31 commit 940ff34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/constructs/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,10 @@ class Interface {
return internal.target[implSymbol][utils.asyncIteratorReturn](this, value);
};
const returnPromise = internal.ongoingPromise ?
internal.ongoingPromise = internal.ongoingPromise ?
internal.ongoingPromise.then(returnSteps, returnSteps) :
returnSteps();
return returnPromise.then(() => newObjectInRealm(globalObject, { value, done: true }));
return internal.ongoingPromise.then(() => newObjectInRealm(globalObject, { value, done: true }));
}
`;
}
Expand Down
8 changes: 4 additions & 4 deletions test/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1254,10 +1254,10 @@ exports.install = (globalObject, globalNames) => {
return internal.target[implSymbol][utils.asyncIteratorReturn](this, value);
};

const returnPromise = internal.ongoingPromise
internal.ongoingPromise = internal.ongoingPromise
? internal.ongoingPromise.then(returnSteps, returnSteps)
: returnSteps();
return returnPromise.then(() => newObjectInRealm(globalObject, { value, done: true }));
return internal.ongoingPromise.then(() => newObjectInRealm(globalObject, { value, done: true }));
}
});

Expand Down Expand Up @@ -12630,10 +12630,10 @@ exports.install = (globalObject, globalNames) => {
return internal.target[implSymbol][utils.asyncIteratorReturn](this, value);
};

const returnPromise = internal.ongoingPromise
internal.ongoingPromise = internal.ongoingPromise
? internal.ongoingPromise.then(returnSteps, returnSteps)
: returnSteps();
return returnPromise.then(() => newObjectInRealm(globalObject, { value, done: true }));
return internal.ongoingPromise.then(() => newObjectInRealm(globalObject, { value, done: true }));
}
});

Expand Down

0 comments on commit 940ff34

Please sign in to comment.