From c993f97c5d29f530ee8cb73b72df3e57418dd6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Tue, 3 Jul 2018 07:51:19 +0200 Subject: [PATCH] Capture the unhandled exceptions of the process --- src/internals/index.js | 8 ++++++++ src/main/bridge.js | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/internals/index.js b/src/internals/index.js index 0db57625..252421b7 100644 --- a/src/internals/index.js +++ b/src/internals/index.js @@ -11,6 +11,14 @@ require('../env') process.title = 'Internal' +process.on('uncaughtException', err => { + process.send({ + type: 'uncaughtException', + error: serializeError(err), + }) + process.exit(1) +}) + const defers = {} let sentryEnabled = process.env.INITIAL_SENTRY_ENABLED || false diff --git a/src/main/bridge.js b/src/main/bridge.js index 5ed618b2..154a7110 100644 --- a/src/main/bridge.js +++ b/src/main/bridge.js @@ -7,8 +7,9 @@ import { ipcMain, app } from 'electron' import { ipcMainListenReceiveCommands } from 'helpers/ipc' import path from 'path' import logger from 'logger' -import sentry from 'sentry/node' +import sentry, { captureException } from 'sentry/node' import user from 'helpers/user' +import { deserializeError } from 'helpers/errors' import setupAutoUpdater, { quitAndInstall } from './autoUpdate' import { setInternalProcessPID } from './terminator' @@ -100,6 +101,11 @@ ipcMainListenReceiveCommands({ function handleGlobalInternalMessage(payload) { switch (payload.type) { + case 'uncaughtException': { + const err = deserializeError(payload.error) + captureException(err) + break + } case 'setLibcoreBusy': case 'setDeviceBusy': case 'executeHttpQueryOnRenderer': {