Re-enable unhandledrejection Sentry logging and fix `undefined` message
.
- Re-enable
unhandledrejection
Sentry logging, https://github.com/troupe/gitter-webapp/issues/1056- Ignore
TransportError
andBayeuxError
that come fromgitter-realtime-client
->halley
to avoid polluting Sentry. We are already using an up-to-dategitter-realtime-client
that has the latesthalley
with those errors-
Update 2018-5-7: We are using
halley@0.4.8
which is the latest on npm currently but this doesn't useTransportError
yet.
-
Update 2018-5-7: We are using
- Ignore
- Fix
undefined
message events in Sentry, https://gitlab.com/gitlab-org/gitter/webapp/issues/1889 - Add best practice
ignoreErrors
/ignoreUrls
Setry Raven.js config, https://docs.sentry.io/clients/javascript/tips/#decluttering-sentry
undefined
message Sentry events
Fixing Example events,
- https://sentry.gitlap.com/gitlab/frontend-staging/issues/182909/
- https://sentry.gitlap.com/gitlab/frontend-dev/issues/184201/
This was caused by the built-in Raven.js error handling Bluebird errors that are not spec compliant, missing PromiseRejectionEvent
-> e.reason
. Bluebird promises use e.detail.reason
. The only Bluebird docs I could find around e.detail
was "parameters are properties of the event detail property". There is an issue to track spec-compliance, https://github.com/petkaantonov/bluebird/issues/1509, and we just need to wait for a new Bluebird version.
They even mention Bluebird by name as should be working fine.
Bluebird and other promise libraries report unhandled rejections to a global DOM event, unhandledrejection. In this case, you don't need to do anything, we've already got you covered by with default captureUnhandledRejections: true setting.
https://github.com/getsentry/raven-js/blob/master/docs/usage.rst#promises
Here are some barebones demos that show off e.reason
vs e.detail.reason
- Native promise, https://jsfiddle.net/f9zjzh61/
- Bluebird (latest 3.5.0), https://jsfiddle.net/6ucwn023/
I disabled the built-in Raven.js unhandledrejection
handling with the captureUnhandledRejections
Raven config. Then re-enabled our own custom unhandledrejection
handling which was previously disabled because halley
was polluting Sentry. halley
is now up-to-date in gitter-realtime-client
so we are all good there.
Testing
I tested that we no longer get undefined
Sentry messages (just cause any uncaught error).
I tested that TransportError
and BayeuxError
are ignored,
function defineProperty(obj, name, value) {
Object.defineProperty(obj, name, {
value: value,
configurable: true,
enumerable: false,
writable: true
});
}
function BayeuxError(message) {
if (!(this instanceof BayeuxError)) return new BayeuxError(message);
var code, params, m;
message = message || '';
var match = /^([\d]+):([^:]):(.)$/.exec(message);
if (match) {
code = parseInt(match[1], 10);
params = match[2].split(',');
m = match[3];
}
defineProperty(this, "message", m || message || "bayeuxError");
defineProperty(this, "name", "BayeuxError");
defineProperty(this, "code", code);
defineProperty(this, "params", params);
defineProperty(this, "bayeuxMessage", m);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
} else {
Error.call(this);
}
}
BayeuxError.prototype = Object.create(Error.prototype);
BayeuxError.prototype.constructor = BayeuxError;
Promise.resolve()
.then(() => {
throw new BayeuxError('some error');
});
Closes https://gitlab.com/gitlab-org/gitter/webapp/issues/1889, https://github.com/troupe/gitter-webapp/issues/1056