Skip to content

Close sync iterables when they yield rejected promises #49

@js-choi

Description

@js-choi

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions