mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 15:56:10 +08:00
More aggressively throttle Sentry reporting of mailsync
This commit is contained in:
parent
bb0ef0b86e
commit
9e88881f36
|
@ -36,9 +36,10 @@ class PreferencesGeneral extends React.Component {
|
||||||
_onResetEmailCache = () => {
|
_onResetEmailCache = () => {
|
||||||
rimraf(path.join(AppEnv.getConfigDirPath(), 'edgehill.*'), err => {
|
rimraf(path.join(AppEnv.getConfigDirPath(), 'edgehill.*'), err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return AppEnv.showErrorDialog(
|
return AppEnv.showErrorDialog({
|
||||||
`Could not delete the mail database. Please delete the "edgehill.db" file in ${AppEnv.getConfigDirPath()} manually.\n\n${err.toString()}`
|
title: `Could not delete the mail database.`,
|
||||||
);
|
message: `Please quit Mailspring and delete the "edgehill.db" file in ${AppEnv.getConfigDirPath()} manually.\n\n${err.toString()}`,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this._onReboot();
|
this._onReboot();
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,6 +18,7 @@ import Actions from './actions';
|
||||||
import Utils from './models/utils';
|
import Utils from './models/utils';
|
||||||
|
|
||||||
const MAX_CRASH_HISTORY = 10;
|
const MAX_CRASH_HISTORY = 10;
|
||||||
|
const REPORTED_CRASH_STACKS = {};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This class keeps track of how often Mailsync workers crash. If a mailsync
|
This class keeps track of how often Mailsync workers crash. If a mailsync
|
||||||
|
@ -41,36 +42,9 @@ class CrashTracker {
|
||||||
delete this._tooManyFailures[key];
|
delete this._tooManyFailures[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
recordClientCrash(fullAccountJSON, { code, error, signal }) {
|
tailClientLog(accountId) {
|
||||||
this._appendCrashToHistory(fullAccountJSON);
|
|
||||||
|
|
||||||
const overview = `SyncWorker crashed with ${signal} (code ${code})`;
|
|
||||||
let [message, stack] = `${error}`.split('*** Stack trace');
|
|
||||||
|
|
||||||
if (message) {
|
|
||||||
const lines = message
|
|
||||||
.split('\n')
|
|
||||||
.map(l => l.replace(/\*\*\*/g, '').trim())
|
|
||||||
.filter(l => !/^[\d|[ ]+/.test(l) && !l.startsWith('Error: null'));
|
|
||||||
message = `${overview}:\n${lines.join('\n')}`;
|
|
||||||
}
|
|
||||||
if (stack) {
|
|
||||||
const lines = stack.split('\n').map(l =>
|
|
||||||
l
|
|
||||||
.replace(/\*\*\*/g, '')
|
|
||||||
.replace('in mailsync ', '')
|
|
||||||
.trim()
|
|
||||||
);
|
|
||||||
lines.shift();
|
|
||||||
message = `${message}${lines[0]}`;
|
|
||||||
stack = lines.join('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
const err = new Error(message);
|
|
||||||
err.stack = stack;
|
|
||||||
|
|
||||||
let log = '';
|
let log = '';
|
||||||
const logfile = `mailsync-${fullAccountJSON.id}.log`;
|
const logfile = `mailsync-${accountId}.log`;
|
||||||
try {
|
try {
|
||||||
const logpath = path.join(AppEnv.getConfigDirPath(), logfile);
|
const logpath = path.join(AppEnv.getConfigDirPath(), logfile);
|
||||||
const { size } = fs.statSync(logpath);
|
const { size } = fs.statSync(logpath);
|
||||||
|
@ -83,12 +57,50 @@ class CrashTracker {
|
||||||
} catch (logErr) {
|
} catch (logErr) {
|
||||||
console.warn(`Could not append ${logfile} to mailsync exception report: ${logErr}`);
|
console.warn(`Could not append ${logfile} to mailsync exception report: ${logErr}`);
|
||||||
}
|
}
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
|
||||||
AppEnv.errorLogger.reportError(err, {
|
recordClientCrash(fullAccountJSON, { code, error, signal }) {
|
||||||
stack: stack,
|
this._appendCrashToHistory(fullAccountJSON);
|
||||||
log: log,
|
|
||||||
provider: fullAccountJSON.provider,
|
let [rawMessage, rawStack] = `${error}`.split('*** Stack trace');
|
||||||
});
|
|
||||||
|
// On Windows, sometimes addr2line.exe fails and the resulting error
|
||||||
|
// is not worth reporting...
|
||||||
|
if (rawMessage.includes('CREATE PROCESS FAIL')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let stack = '';
|
||||||
|
if (rawStack) {
|
||||||
|
for (const rawLine of rawStack.split('\n').slice(1)) {
|
||||||
|
const line = rawLine
|
||||||
|
.replace(/\*\*\*/g, '')
|
||||||
|
.replace('in mailsync ', '')
|
||||||
|
.trim();
|
||||||
|
if (!line.startsWith('(unknown)')) {
|
||||||
|
stack += line;
|
||||||
|
stack += '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// because we intentionally retry after exceptions, errors can be reported
|
||||||
|
// to Sentry a zillion times. Only report unique crashes once each time the
|
||||||
|
// app is run.
|
||||||
|
if (!REPORTED_CRASH_STACKS[stack]) {
|
||||||
|
REPORTED_CRASH_STACKS[stack] = true;
|
||||||
|
|
||||||
|
const err = new Error(`SyncWorker crashed with ${signal} (code ${code})`);
|
||||||
|
err.stack = stack;
|
||||||
|
|
||||||
|
AppEnv.errorLogger.reportError(err, {
|
||||||
|
stack: stack,
|
||||||
|
rawMessage: rawMessage,
|
||||||
|
provider: fullAccountJSON.provider,
|
||||||
|
log: this.tailClientLog(fullAccountJSON.id),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_keyFor({ id, settings }) {
|
_keyFor({ id, settings }) {
|
||||||
|
|
Loading…
Reference in a new issue