Skip to content

Revamp Async Generator Error handling #287

@brainkim

Description

@brainkim

Description:
In 0.7, async generator components which throw errors can cause unhandled promise rejections, even if the errors are caught by parent executions. For instance:

async function *Child() {
  for await ({children} of this) {
    throw new Error("this is handled");
  }
}

try {
  await renderer.render(<Child />, document.body);
} catch (err) {
  // renderer.render throws the error but an unhandled promise rejection still happens internally.
}

This issue has affected Crank in various forms for a while now.

The tricky thing is:

  • errors which happen in the course of rendering should cause parent render() and refresh() calls to throw.

  • because these calls throw, there should be no unhandled promise rejections.

  • errors which happen because an async generator component continues after a yield should cause an unhandled promise rejection, because there is no call that can throw for this execution.

  • these cases should be handled by parent sync/async generator components.

  • errors which happen during unmounting should not be catchable by parent components. They should cause unhandled promise rejections instead.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions