Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderAsync can throw synchronously, should return a rejected promise instead? #223

Open
tomyam1 opened this issue Oct 1, 2019 · 1 comment

Comments

@tomyam1
Copy link

tomyam1 commented Oct 1, 2019

This can happen, for instance, if the underlying transformer only supports render.

It will throw synchronously when calling it.

A simple solution would be to wrap all calls to the jstransformer in a try-catch.

What do you think?

More thoughts:

  1. It's bad that renderAsync can do that because other modules don't expect an async function to throw synchronously, e.g. (fix) add filename when jstransformer throws synchronously metalsmith/in-place#174

  2. It's not an issue with the underlying jstransformer because it supports render which can throw synchronously.

@ForbesLindesay
Copy link
Member

Yes, we should wrap in a try catch to handle synchronous errors. I'd be happy to accept a pull request for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants