Skip to content

Commit

Permalink
Revert "fix: omit getQueryResponse function from structured cloning"
Browse files Browse the repository at this point in the history
This reverts commit 84057f7.
  • Loading branch information
titanism committed Dec 19, 2024
1 parent 84057f7 commit 665b8a1
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions helpers/logger.js
Original file line number Diff line number Diff line change
@@ -283,20 +283,12 @@ for (const level of logger.config.levels) {
// <https://nodejs.org/api/globals.html#structuredclonevalue-options>
// <https://github.com/ungap/structured-clone>
try {
//
// structuredClone cannot clone functions and hterefore this would throw something like:
//
// DOMException [DataCloneError]: function getQueryResponse(query, message, options = {}, instance, session) {
// options = options || {};
//
// if (...<omitted>...
// } could not be cloned.
//
// as far as we know this is the only function bound here
message =
typeof message.getQueryResponse === 'function' && _
? global.structuredClone(_.omit(message, ['getQueryResponse']))
: global.structuredClone(message);
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));
@@ -308,11 +300,12 @@ for (const level of logger.config.levels) {
// <https://nodejs.org/api/globals.html#structuredclonevalue-options>
// <https://github.com/ungap/structured-clone>
try {
// see note above regarding functions
meta =
typeof meta.getQueryResponse === 'function' && _
? global.structuredClone(_.omit(meta, ['getQueryResponse']))
: global.structuredClone(meta);
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));

0 comments on commit 665b8a1

Please sign in to comment.