Skip to content

will it always close sync iterators? #39

@vadzim

Description

@vadzim

for await is known to not close sync iterables if rejected promise is emited.
Like

function* It() {
  try {
    yield Promise.resolve("a")
    yield Promise.reject("b")
  } finally {
    console.log("finalized")
  }
}

// prints "a" and never prints "finalized"
for await (const x of It()) { console.log(x) }

// prints "a" and then prints "finalized"
for (const x of It()) { console.log(await x) }

which of theses behaviors will implement Array.fromAsync?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions