Skip to content

ref: Better UnhandledRejection messages #2185

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

Merged
merged 1 commit into from
Aug 5, 2019

Conversation

kamilogorek
Copy link
Contributor

Unfortunately, SyntheticExceptions are no-go, as promises just don't provide stack traces, even when Error objects manually create after the fact. It'll capture Tracekit global handler only, not original calls.

This change will most likely cause some events to re-appear with better messages for some of the clients.


Setup:

Screenshot 2019-07-31 at 13 24 32


Before:

Screenshot 2019-07-31 at 13 33 31

Screenshot 2019-07-31 at 13 33 39


After:

Screenshot 2019-07-31 at 13 35 46

Screenshot 2019-07-31 at 13 35 52


It'd be nice to be able to show users some info regarding using Error objects for rejections, but I'm almost certain we shouldn't do this in the SDK. We already have all the data we need to do this in the UI (mechanism.type and mechanism.data.incomplete). Not sure about this change yet though, we can iterate.

@kamilogorek kamilogorek requested review from dcramer and HazAT July 31, 2019 11:47
@getsentry-bot
Copy link
Contributor

getsentry-bot commented Jul 31, 2019

Warnings
⚠️ Please add a changelog entry for your changes.
Messages
📖 ✅ TSLint passed
📖

@sentry/browser bundle gzip'ed minified size: (ES5: 16.0566 kB) (ES6: 15.2588 kB)

Generated by 🚫 dangerJS against 7f2281c

@lobsterkatie
Copy link
Member

I think this will be really helpful - thanks, @kamilogorek!

Question: if someone does this

class Dog { 
  constructor(name) {
    this.name = name;
  }
}

new Promise(() => {
  throw new Dog("Fido");
  // note: never throw your dog - it's mean
});

will that be handled the same way throw {plain: "object"} is?

@kamilogorek
Copy link
Contributor Author

@lobsterkatie correct.

This would behave like error and have a stacktrace:

class Dog extends Error { 
  constructor(name) {
    super(name);
    this.name = name;
  }
}

new Promise(() => {
  throw new Dog("Fido");
  // note: never throw your dog - it's mean
});

@lobsterkatie
Copy link
Member

Right, that makes sense. Thanks for the confirmation!

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 this pull request may close these issues.

3 participants