From d7d7b304cf6b10388249803822b209a3573d0168 Mon Sep 17 00:00:00 2001 From: titanism <101466223+titanism@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:58:14 -0600 Subject: [PATCH] fix: fixed structuredClone bug with try/catch for now --- helpers/logger.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/helpers/logger.js b/helpers/logger.js index f946cfdd6c..094dff6108 100644 --- a/helpers/logger.js +++ b/helpers/logger.js @@ -282,24 +282,34 @@ for (const level of logger.config.levels) { // clone the data so that we don't mutate it // // - message = global.structuredClone(message, { - // avoid throwing - lossy: true, - // avoid throwing *and* looks for toJSON - json: true - }); + try { + message = global.structuredClone(message, { + // avoid throwing + lossy: true, + // avoid throwing *and* looks for toJSON + json: true + }); + } catch (err) { + console.error({ message, err }); + message = JSON.parse(safeStringify(message)); + } } if (typeof meta === 'object' && global.structuredClone) { // clone the data so that we don't mutate it // // - meta = global.structuredClone(meta, { - // avoid throwing - lossy: true, - // avoid throwing *and* looks for toJSON - json: true - }); + try { + meta = global.structuredClone(meta, { + // avoid throwing + lossy: true, + // avoid throwing *and* looks for toJSON + json: true + }); + } catch (err) { + console.error({ meta, err }); + message = JSON.parse(safeStringify(message)); + } } // add `isCodeBug` parsing here to `err` (safeguard)