Improve error handling during group sends
This commit is contained in:
parent
f0a3735ca2
commit
991580a1ed
58 changed files with 299 additions and 324 deletions
|
@ -19,6 +19,7 @@ import { read as readLastLines } from 'read-last-lines';
|
|||
import rimraf from 'rimraf';
|
||||
|
||||
import type { LoggerType } from '../types/Logging';
|
||||
import * as Errors from '../types/errors';
|
||||
import * as durations from '../util/durations';
|
||||
import { createRotatingPinoDest } from '../util/rotatingPinoDest';
|
||||
|
||||
|
@ -67,7 +68,9 @@ export async function initialize(
|
|||
try {
|
||||
await cleanupLogs(logPath);
|
||||
} catch (error) {
|
||||
const errorString = `Failed to clean logs; deleting all. Error: ${error.stack}`;
|
||||
const errorString =
|
||||
'Failed to clean logs; deleting all. ' +
|
||||
`Error: ${Errors.toLogFormat(error)}`;
|
||||
console.error(errorString);
|
||||
await deleteAllLogs(logPath);
|
||||
mkdirp.sync(logPath);
|
||||
|
@ -136,7 +139,7 @@ export async function initialize(
|
|||
...rest,
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error(`Problem loading log data: ${error.stack}`);
|
||||
logger.error(`Problem loading log data: ${Errors.toLogFormat(error)}`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -151,7 +154,7 @@ export async function initialize(
|
|||
try {
|
||||
await deleteAllLogs(logPath);
|
||||
} catch (error) {
|
||||
logger.error(`Problem deleting all logs: ${error.stack}`);
|
||||
logger.error(`Problem deleting all logs: ${Errors.toLogFormat(error)}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -196,7 +199,7 @@ async function cleanupLogs(logPath: string) {
|
|||
} catch (error) {
|
||||
console.error(
|
||||
'Error cleaning logs; deleting and starting over from scratch.',
|
||||
error.stack
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
|
||||
// delete and re-create the log directory
|
||||
|
@ -215,7 +218,7 @@ export function isLineAfterDate(line: string, date: Readonly<Date>): boolean {
|
|||
const data = JSON.parse(line);
|
||||
return new Date(data.time).getTime() > date.getTime();
|
||||
} catch (e) {
|
||||
console.log('error parsing log line', e.stack, line);
|
||||
console.log('error parsing log line', Errors.toLogFormat(e), line);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import {
|
|||
} from './shared';
|
||||
import * as log from './log';
|
||||
import { Environment, getEnvironment } from '../environment';
|
||||
import * as Errors from '../types/errors';
|
||||
import { createRotatingPinoDest } from '../util/rotatingPinoDest';
|
||||
|
||||
// Backwards-compatible logging, simple strings and no level (defaulted to INFO)
|
||||
|
@ -114,14 +115,13 @@ window.SignalContext.log = {
|
|||
};
|
||||
|
||||
window.onerror = (_message, _script, _line, _col, error) => {
|
||||
const errorInfo = error && error.stack ? error.stack : JSON.stringify(error);
|
||||
const errorInfo = Errors.toLogFormat(error);
|
||||
log.error(`Top-level unhandled error: ${errorInfo}`);
|
||||
};
|
||||
|
||||
window.addEventListener('unhandledrejection', rejectionEvent => {
|
||||
const error = rejectionEvent.reason;
|
||||
const errorString =
|
||||
error && error.stack ? error.stack : JSON.stringify(error);
|
||||
const errorString = Errors.toLogFormat(error);
|
||||
log.error(`Top-level unhandled promise rejection: ${errorString}`);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue