question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Errors inside raven swallow the original error

See original GitHub issue

Using raven-js 3.24.0 installed via npm, in Angular 5.

What is the current behavior?

If an error happens while reporting an event to sentry, raven blows up and throws an error in the console. For example, if I have origin filtering enabled on sentry and run my website locally, raven receives a 403 and swallows the original exception.

image

What is the expected behavior?

Raven should never do anything that prevents the real error from reaching termination, i.e. the application error should always be rethrown. If an error hapens in raven code, it should be caught, logged and the app’s error be rethrown.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kamilogorekcommented, Apr 18, 2018

Ok, let’s dissect what’s happening here, as everything is working just fine, but manual rethrows make it look odd (ignore my previous comment, zone.js just made it harder to debug due to its “wrap everything i can” nature).

  • call Raven.config().install()
  • throw an error in the component
  • error is caught by handleError method
  • call Raven.captureException(err);, it’s sent to sentry (403 is not that important here)
  • then rethrow this error with throw err;

And now, what’s actually happening:

  • by calling install() you attach global error handlers
  • when doing captureException inside your handleError method, you capture it with Raven
  • when you rethrow it, it’s not captured by handleError method anymore, as it’s not in the bubble chain - what happens then, is that error is caught by global onerror handler that you attached using install() method
  • our onerror handler captures your rethrow and tries to send it
  • however, because it’s the very same error that you just caught yourself, it’s deduped and dropped (see allowDuplicates option - https://docs.sentry.io/clients/javascript/config/)
  • you don’t see any logging, because you don’t use debug mode as described in our docs (please note that previous method - Raven.debug = true was broken in TypeScript which you use, so you can use Raven.config(DSN, { debug: true }) now with newest 3.24.2 release as well)

Here is how your console will look in various configurations (note that I used 401 [invalid dsn] to simulate 403 behavior - it will be the same).


// No `install` - rethrown error wont be caught
Raven.config(DSN)

screen shot 2018-04-18 at 14 24 48


// No `install` - rethrown error wont be caught
Raven.config(DSN, {
  debug: true
})

screen shot 2018-04-18 at 14 25 11


// Current behavior
Raven.config(DSN).install()

screen shot 2018-04-18 at 14 23 31


Raven.config(DSN, {
  debug: true
}).install()

screen shot 2018-04-18 at 14 24 07


Raven.config(DSN, {
  allowDuplicates: true
}).install()

screen shot 2018-04-18 at 14 23 49


Raven.config(DSN, {
  allowDuplicates: true,
  debug: true
}).install()

screen shot 2018-04-18 at 14 24 30


Hopefully it makes everything much clearer. Let me know if you have any more questions.

1reaction
john-kurkowskicommented, Apr 18, 2018

Yeah, nice breakdown, @kamilogorek. I think that’ll serve readers for time to come, even for those without this exact issue.

One nitpick:

you don’t see any logging, because you don’t use debug mode as described in our docs

The docs say

debug

If set to true, Raven.js outputs some light debugging information onto the console.

This doesn’t tell me what I’m going to get. Will the debugging information be for me? For my users? For Raven.js developers? Should I avoid in production? Will it print the original error?

That last one is the reason I came to this thread. I was hoping for such an option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Raven | Explaining errors in Star Trek Wiki | Fandom
Murray Leeder on Sunday, December 20, 1998 - 10:39 pm: The problem is that the crew of Voyager DO NOT SEEM IN THE...
Read more >
es6 promises swallow type errors - javascript - Stack Overflow
Using your second example, I get the following error in my console TypeError: Cannot set property 'otherthing' of undefined . · i want...
Read more >
Facts about Crows - WDFW
Crows and ravens belong in the Corvid family. (which includes jays and magpies) and are considered to be among the most adaptable and...
Read more >
Accidental aspiration/ingestion of foreign bodies in dentistry
Although anything introduced in the oral cavity can potentially lead to a mishap, the swallowing of some foreign objects is more common than...
Read more >
Mnemonic Seed - A simple explanation of BIP39.
Encoding a random number in to words and using them to create a seed. ... First of all, we add a checksum to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found