Skip to content

Commit b6928ca

Browse files
authored
Merge pull request #411 from mitchhentges/fix-sentry-exit-uncaught-exception
Updates sentry, removes UncaughtException integration
2 parents 08ac9bf + 73d280a commit b6928ca

File tree

4 files changed

+65
-49
lines changed

4 files changed

+65
-49
lines changed

package-lock.json

Lines changed: 46 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
},
2929
"dependencies": {
3030
"@james-proxy/james-browser-launcher": "^1.3.2",
31-
"@sentry/browser": "^4.0.2",
32-
"@sentry/node": "^4.0.1",
31+
"@sentry/browser": "^4.5.3",
32+
"@sentry/node": "^4.5.3",
3333
"electron-updater": "3.1.2",
3434
"font-awesome": "^4.5.0",
3535
"history": "^4.7.2",

src/common/service/sentry.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default function init(app, Sentry) {
99
const { dsn, host } = config.sentry;
1010
Sentry.init({
1111
dsn: `https://${dsn}@${host}`,
12-
release: config.version(app)
12+
release: config.version(app),
13+
defaultIntegrations
1314
});
1415
}

src/main/index.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,21 @@ import createUrlMapper from './url-mapper.js';
1313
import createProxy from './proxy.js';
1414
import autoUpdater from './auto-update.js';
1515

16-
sentryInit(app, Sentry);
16+
import * as sentryNode from '@sentry/node';
17+
18+
// TODO remove this global handler and Sentry integration override!
19+
// See bug: https://github.com/james-proxy/james/issues/405
20+
process.on('uncaughtException', (error) => {
21+
console.warn('Ignored fatal error!', error); // eslint-disable-line no-console
22+
Sentry.captureException(error);
23+
});
24+
25+
// Replace default onFatalError implementation (that kills the process) with a noop
26+
// Uncaught exceptions will be reported to exceptions manually in our override handler above
27+
const defaultIntegrations = sentryNode.defaultIntegrations
28+
.filter(integration => !(integration instanceof sentryNode.Integrations.OnUncaughtException));
29+
30+
sentryInit(app, Sentry, defaultIntegrations);
1731
// Keep a global reference of the window object, if you don't, the window will
1832
// be closed automatically when the javascript object is GCed.
1933
let mainWindow = null;
@@ -24,11 +38,6 @@ const urlMapper = createUrlMapper({
2438
autoload: true
2539
});
2640

27-
process.on('uncaughtException', (error) => {
28-
// TODO remove this global handler!
29-
console.warn('Ignored fatal error!', error); // eslint-disable-line no-console
30-
});
31-
3241
console.log('Starting proxy...'); // eslint-disable-line no-console
3342
const proxy = createProxy(config, urlMapper.urlMapper);
3443

0 commit comments

Comments
 (0)