From 37c6c2d4a761bae6d8a11fe424fc3260325bbfdd Mon Sep 17 00:00:00 2001 From: Ben White Date: Thu, 5 Sep 2024 13:59:41 +0200 Subject: [PATCH] Fixes --- plugin-server/src/utils/status.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin-server/src/utils/status.ts b/plugin-server/src/utils/status.ts index d4bb164bb25e5..0b6b8f26ca1c5 100644 --- a/plugin-server/src/utils/status.ts +++ b/plugin-server/src/utils/status.ts @@ -67,7 +67,14 @@ export class Status implements StatusBlueprint { const logMessage = `[${this.prompt}] ${icon} ${message}` if (!this.logger) { - throw new Error(`Logger has been closed! Cannot log: ${logMessage}`) + if (isProdEnv()) { + // This can throw on tests if the logger is closed. We don't really want tests to be bothered with this. + throw new Error(`Logger has been closed! Cannot log: ${logMessage}`) + } + console.log( + `Logger has been closed! Cannot log: ${logMessage}. Logging to console instead due to non-prod env.` + ) + return } if (extra instanceof Object) { this.logger[type]({ ...extra, msg: logMessage })