-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Previously, for await
did not close sync iterables when they yield rejected promises (tc39/ecma262#1849):
Code example
function * createIter() {
try {
yield Promise.resolve(console.log("a"));
yield Promise.reject("x");
} finally {
console.log("finalized");
}
}
// Prints "a" and then prints "finalized".
// There is an uncaught "x" rejection.
for (const x of createIter()) {
console.log(await x);
}
// Prints "a" and then prints "finalized".
// There is an uncaught "x" rejection.
Array.from(createIter());
A month ago, the editors merged tc39/ecma262#2600 into the language. Now, for await
closes sync iterables when they yield rejected promises. Array.fromAsync needs to change to do the same. See #39.
- Update spec
- Update explainer section
- Update test262
- Open an issue on MDN