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 in Chrome Extension Message Handlers not Logged

See original GitHub issue

Package + Version

  • @sentry/browser

Version:

5.5.0

Description

I am using Sentry to instrument a Chrome Extension. For the most part this works well.

However, uncaught errors in listeners registered via:

chrome.runtime.onMessage.addListener

are surprisingly not logged by sentry.

Note that uncaught errors in these handlers have a slightly different form when printed to the console. A normal uncaught error might log like this:

Uncaught TypeError: XYZ

While errors in the onMessage handler log something like:

Error in event handler: TypeError: XYZ

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kamilogorekcommented, Aug 5, 2019

@scottfr async messages are not bubbling up to the main onerror listener, as they are meant to be used in communication between channels.

Your best bet here (which works just fine, tested it locally) is to use Sentry.wrap

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
  Sentry.wrap(function() {
    throw new Error(
    "I am an error registered in an onMessage handler. I will incorrectly not be logged to sentry. You will still see me in the console."
    );
  });
});
1reaction
scottfrcommented, Aug 5, 2019

OK, sounds good. Thanks for looking into this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does Chrome onerror handler not return full error ...
@Ivar yes, chrome's error handling does show the full message, but the problem is that the custom onerror handler's message is not the...
Read more >
chrome.scripting - Chrome Developers
Use the chrome.scripting API to execute script in different contexts. Permissions ... An object to filter the extension's dynamically registered scripts.
Read more >
Set Chrome policies for users or browsers - Google Support
Enrolled browsers to enforce policies when users open Chrome browser on managed Microsoft Windows, Apple Mac, or Linux computers. Signing in is not...
Read more >
Extension errors should trigger the global onerror event.
Currently, many extension errors (chrome/renderer/resources/extensions/*.js) are just logged by calling console.error. In addition to printing the error to ...
Read more >
Manifest V3 service worker registration failed - Google Groups
I cannot think of what else to do and the error message does not give any ... on the chrome://extensions page, then I...
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