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

UnhandledPromiseRejectionWarning (node) / Uncaught (in promise) (browser) when passing text as undefined #678

Closed
gytisgreitai opened this issue Feb 21, 2020 · 3 comments · Fixed by #695
Assignees
Milestone

Comments

@gytisgreitai
Copy link

node code:

  try {
    slide.addText([{text: undefined, options: {breakLine: true}}], {x:1, y:1, w: 1, h:1})
  } catch (e) {
    console.log('this will not be invoked')
    console.error(e)
  }

Fails with:

(node:63649) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().

Example to reproduce in browser:

Fiddle: https://jsfiddle.net/6ayzoxh2/

Clearly this is an error on my side, and I should not pass the undefined text, but it would be cool if your code would throw, then I could handle it

@ankon
Copy link
Contributor

ankon commented Mar 6, 2020

We're getting hit by this as well.

The problem indeed is that one cannot even catch this exception at all, so all our "defensive coding" didn't help.

I'm right now looking into this, and a very initial hunch is that the whole save code is failing to properly reject the involved promises.

@ankon
Copy link
Contributor

ankon commented Mar 6, 2020

Note that the error only happens when actually writing the output, not at the time you call addSlide.

I agree that it would be useful to know which slide had the issue, but that seems like a lot of error checking that would need to be added.

The TypeScript definitions define that text must not be null/undefined, so if you use TypeScript and have proper types everywhere in your app there's a good chance that you'll be able to catch the error at development time rather than at runtime.

@gitbrent gitbrent linked a pull request May 10, 2020 that will close this issue
@gitbrent gitbrent added this to the 3.2.0 milestone May 10, 2020
@gitbrent
Copy link
Owner

This is fixed thanks to Pull #695

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

Successfully merging a pull request may close this issue.

3 participants