Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const setupErrorHandling = (appType) => {
if (remote) {
// eslint-disable-next-line no-proto
setTimeout(() => {}).__proto__.unref = () => {};
}
const handleError = (error) => {
logger.error(error && (error.stack || error));
!remote && app.quit(1);
};
if (process.env.BUGSNAG_API_KEY) {
bugsnagClient = bugsnag({
apiKey: process.env.BUGSNAG_API_KEY,
appVersion: app.getVersion(),
appType,
collectUserIp: false,
onUncaughtException: handleError,
onUnhandledRejection: handleError,
releaseStage: process.env.NODE_ENV,
});
return;
}
process.on('uncaughtException', handleError);
process.on('unhandledRejection', handleError);
};