From d84a5767bf1708e58de800349b60e92b0b9424a2 Mon Sep 17 00:00:00 2001 From: tamaina Date: Mon, 4 Mar 2024 12:07:03 +0000 Subject: [PATCH] force one-line log (queue processor) --- .../src/queue/QueueProcessorService.ts | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/backend/src/queue/QueueProcessorService.ts b/packages/backend/src/queue/QueueProcessorService.ts index e05fe20458..32e8146f55 100644 --- a/packages/backend/src/queue/QueueProcessorService.ts +++ b/packages/backend/src/queue/QueueProcessorService.ts @@ -68,6 +68,25 @@ function getJobInfo(job: Bull.Job | undefined, increment = false): string { return `id=${job.id} attempts=${currentAttempts}/${maxAttempts} age=${formated}`; } +function renderError(e: Error): any { + if (e) { // 何故かeがundefinedで来ることがある + return { + ...Object.getOwnPropertyNames(e).reduce((acc, key) => { + //@ts-expect-error Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Error'. + acc[key] = e[key]; + return acc; + }, {} as Record), + stack: e.stack?.split('\n').map(s => s.trim()), + }; + } else { + return { + stack: '?', + message: '?', + name: '?', + }; + } +} + @Injectable() export class QueueProcessorService implements OnApplicationShutdown { private logger: Logger; @@ -118,18 +137,6 @@ export class QueueProcessorService implements OnApplicationShutdown { ) { this.logger = this.queueLoggerService.logger; - function renderError(e: Error): any { - if (e) { // 何故かeがundefinedで来ることがある - return e; - } else { - return { - stack: '?', - message: '?', - name: '?', - }; - } - } - //#region system this.systemQueueWorker = new Bull.Worker(QUEUE.SYSTEM, (job) => { switch (job.name) {