stackdriver-errors-js icon indicating copy to clipboard operation
stackdriver-errors-js copied to clipboard

Unhandled exception should still be printed to the Console

Open steren opened this issue 9 years ago • 9 comments

Setting up this module hides errors from the Chrome console. This is not good for debugging

steren avatar Nov 29 '16 15:11 steren

I'm on the fence about this one, while its nice to see the errors, in local development the package should be not initialized. In your live environment, there's little benefit in the users of the application to see the errors, and as a developer you can see all of the errors in the stackdriver dashboard.

Thoughts @steren ?

oshalygin avatar May 16 '17 06:05 oshalygin

That's a good point that in local dev, it's better to not initialize the module.

I still wonder if in a scenario of troubleshooting a customer issue, it's convenient to ask the customer: "open the Chrome console, is there any errors there?".

steren avatar May 16 '17 12:05 steren

Very good point!

oshalygin avatar May 16 '17 20:05 oshalygin

I would definitely agree with @steren in this case, but it should be an option which could be turned off in config if someone would still want to run logging silently.

Jastrzebowski avatar Nov 15 '17 10:11 Jastrzebowski

You should not break default browser behaviour. Sometimes one need to check by himself that is an error somewhere without access to stackdriver. How could he know that this script is running and errors are suppresed? It can lead to many problems.

For those who needs fix for this, just change return value of this function in source code from true to false: window.onerror = function(message, source, lineno, colno, error) { if(error){ that.report(error); } oldErrorHandler(message, source, lineno, colno, error); return true; };

Line 74 in current version

and then rebuild (npm run dist).

michalzubkowicz avatar Aug 28 '18 16:08 michalzubkowicz

What about just make this configurable?

aaomidi avatar Oct 21 '18 04:10 aaomidi

another possible workaround:

import StackdriverErrorReporter from "stackdriver-errors-js";

const errorReporter = new StackdriverErrorReporter();

function startReportingUnhanldedErrors() {
  // 1. report errors to stackdriver
  errorReporter.start(YOUR_CONFIG);
  const stackdriverErrorHandler = window.onerror;
  window.onerror = () => {
    stackdriverErrorHandler(...arguments);
    // 2. log errors to the console (default browser behavior)
    return false;
  };
}

amirnissim avatar Sep 01 '19 12:09 amirnissim

the bad thing is that StackDriver automatically makes the decision for you, violating Inversion of Control. It could be especially bad when there are other handlers that monitor the console (Winston, for example)

should be disabled by default, or configurable.

KutnerUri avatar Nov 17 '19 12:11 KutnerUri

@oshalygin, @steren

  • A lot of small companies, don't have strict QA, and they ship products with bugs and fix bugs on production (hello, can you send the screenshot of the console ?). In this case, Whenever something is not working, we can't go to stackdriver and refresh the screen every few seconds to see any new error is captured.
  • Other error-capturing (ex: sentry) libraries do print unhandled errors on the console. That's what console is for.
  • In local development, I was running this library, with disabled = true, in this mode also errors are swallowed (errors not printed, errors not sent to the server).

palamccc avatar Mar 21 '20 06:03 palamccc