Skip to content

Commit

Permalink
fix(debug): avoid printing trusted symbol in debug output
Browse files Browse the repository at this point in the history
Fix #15263
  • Loading branch information
vkarpov15 committed Feb 21, 2025
1 parent 987f1ad commit 5209a3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/drivers/node-mongodb-native/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const internalToObjectOptions = require('../../options').internalToObjectOptions
const stream = require('stream');
const util = require('util');

const formatToObjectOptions = Object.freeze({ ...internalToObjectOptions, copyTrustedSymbol: false });

/**
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) collection implementation.
*
Expand Down Expand Up @@ -384,7 +386,9 @@ function format(obj, sub, color, shell) {
}

const clone = require('../../helpers/clone');
let x = clone(obj, internalToObjectOptions);
// `sub` indicates `format()` was called recursively, so skip cloning because we already
// did a deep clone on the top-level object.
let x = sub ? obj : clone(obj, formatToObjectOptions);
const constructorName = getConstructorName(x);

if (constructorName === 'Binary') {
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function cloneObject(obj, options, isArrayChild) {
} else if (seen) {
seen.set(obj, ret);
}
if (trustedSymbol in obj) {
if (trustedSymbol in obj && options?.copyTrustedSymbol !== false) {
ret[trustedSymbol] = obj[trustedSymbol];
}

Expand Down

0 comments on commit 5209a3c

Please sign in to comment.