sentry-javascript: captureException throws error after it returns leading to an uncaughtException!

Package + Version

  • @sentry/node

Version:

4.4.1

Description

captureException throws an error after it returns. Therefore, it CANNOT be caught by a simple try-catch.

try {
      Sentry.captureException(originalError)
} catch (e) {
      console.log('Sentry Error', e)
}
...
-> Exception is thrown here

WHY/HOW is this an accepted behavior?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 19 (6 by maintainers)

Most upvoted comments

@Getz85 @ntelkedzhiev please read https://github.com/getsentry/sentry-javascript/issues/1449#issuecomment-438237271, https://github.com/getsentry/sentry-javascript/issues/1449#issuecomment-440213796 and https://github.com/getsentry/sentry-javascript/issues/1449#issuecomment-440231440

There’s no reason why you’d ever need to catch Sentry’s http errors that I’m aware of. If you want to change the default delivery behavior, you can use custom transports https://codesandbox.io/s/8z4o9yvl6j Or if you really need to catch them, read comments linked above.

We don’t catch our own errors, thus we won’t create an infinite loop of failed requests.