logError for saveLogLine was again calling the same function causing an infinite loop

This commit is contained in:
Abhinav 2022-10-16 15:58:17 +05:30
parent 519828a954
commit d0555185cf
2 changed files with 11 additions and 8 deletions

View file

@ -83,8 +83,8 @@ function saveLogLine(log: Log) {
logs.push(log);
setLogs(logs);
} catch (e) {
logError(e, 'failed to save log line');
// don't throw
logError(e, 'failed to save log line', undefined, true);
// ignore
}
}

View file

@ -6,17 +6,20 @@ import { getSentryUserID } from 'utils/user';
export const logError = (
error: any,
msg: string,
info?: Record<string, unknown>
info?: Record<string, unknown>,
skipAddLogLine = false
) => {
if (isErrorUnnecessaryForSentry(error)) {
return;
}
const err = errorWithContext(error, msg);
addLogLine(
`error: ${error?.name} ${error?.message} ${
error?.stack
} msg: ${msg} info: ${JSON.stringify(info)}`
);
if (!skipAddLogLine) {
addLogLine(
`error: ${error?.name} ${error?.message} ${
error?.stack
} msg: ${msg} info: ${JSON.stringify(info)}`
);
}
if (isDEVSentryENV()) {
console.log(error, { msg, info });
}