Asynchronous Error capture in Sentry (Javascript)


Recently I am working with Sentry to send exceptions to Server. I see that errors fron most of the immedate javascript execution statements are thrown to Window.onerror or else even If I wrap the code inside Raven.context(); the logs are sent to Server.

I have problem with callbacks; I see that this is not thrown in window.onerror at all (except in ajax errors). I cannot capture it even if it is inside Raven.context().

Ex: Raven.context(function(){
z=1; //throws error to window.onerror as well as logs to Sentry

checkLogin: function(){
             y=1; //error from here is not thrown to window.onerror or logged to Sentry even if it is under 

If I purposefuly wrap the above code
checkLogin: function(){
y=1; //error from here is not thrown to window.onerror but logged to Sentry


Is there any easy way of doing this.
I see already a discussion related to this which talks about limitation

Do you have opinion on the below article. I see all errors are logged to console no matter synchrnous or asynchronous


Can you give me a reproducible minimal example on GitHub to run? I’d be glad to investigate.


My guess at what’s going on here is that Chrome’s tabs.create function is catching any exceptions thrown by the callback function that it accepts. This stackoverflow post seems to confirm that:

Note that we do not claim to, and simply cannot, capture any thrown error - only those which are uncaught or otherwise explicitly captured, perhaps by some framework integrations, instrumentation of error handlers, or otherwise.

So either:

  1. we add some instrumentation for these chrome APIs - unclear what the scope of this is or the demand, seems somewhat niche
  2. users will need to Raven.wrap any callbacks passed to these API methods


Thank you Lewis for your reply.