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); logs.push(log);
setLogs(logs); setLogs(logs);
} catch (e) { } catch (e) {
logError(e, 'failed to save log line'); logError(e, 'failed to save log line', undefined, true);
// don't throw // ignore
} }
} }

View file

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