From 4c01dcd8eb2bb9bed889c76cf4e192ea11914d61 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sat, 27 Feb 2021 17:39:55 +0900 Subject: [PATCH] Fix #7248 (#7250) * Fix #7248 * fix * fix * fix * avoid infinite loop --- src/boot/index.ts | 4 +++- src/services/logger.ts | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/boot/index.ts b/src/boot/index.ts index 7380c4484d..602f6b0e48 100644 --- a/src/boot/index.ts +++ b/src/boot/index.ts @@ -66,7 +66,9 @@ if (!program.quiet) { // Display detail of uncaught exception process.on('uncaughtException', err => { - logger.error(err); + try { + logger.error(err); + } catch { } }); // Dying away... diff --git a/src/services/logger.ts b/src/services/logger.ts index eb2b257dde..c7483d3faa 100644 --- a/src/services/logger.ts +++ b/src/services/logger.ts @@ -94,7 +94,7 @@ export default class Logger { level === 'info' ? this.syslogClient.info : null as never; - send.bind(this.syslogClient)(message); + send.bind(this.syslogClient)(message).catch(() => {}); } else { const Logs = getRepository(Log); Logs.insert({ @@ -106,7 +106,7 @@ export default class Logger { level: level, message: message.substr(0, 1000), // 1024を超えるとログが挿入できずエラーになり無限ループする data: data, - } as Log); + } as Log).catch(() => {}); } } } @@ -116,8 +116,10 @@ export default class Logger { data = data || {}; data.e = x; this.log('error', x.toString(), data, important); + } else if (typeof x === 'object') { + this.log('error', `${(x as any).message || (x as any).name || x}`, data, important); } else { - this.log('error', x, data, important); + this.log('error', `${x}`, data, important); } }