Skip to content

Commit 5209a3c

Browse files
committed
fix(debug): avoid printing trusted symbol in debug output
Fix Automattic#15263
1 parent 987f1ad commit 5209a3c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/drivers/node-mongodb-native/collection.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const internalToObjectOptions = require('../../options').internalToObjectOptions
1313
const stream = require('stream');
1414
const util = require('util');
1515

16+
const formatToObjectOptions = Object.freeze({ ...internalToObjectOptions, copyTrustedSymbol: false });
17+
1618
/**
1719
* A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) collection implementation.
1820
*
@@ -384,7 +386,9 @@ function format(obj, sub, color, shell) {
384386
}
385387

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

390394
if (constructorName === 'Binary') {

lib/helpers/clone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function cloneObject(obj, options, isArrayChild) {
147147
} else if (seen) {
148148
seen.set(obj, ret);
149149
}
150-
if (trustedSymbol in obj) {
150+
if (trustedSymbol in obj && options?.copyTrustedSymbol !== false) {
151151
ret[trustedSymbol] = obj[trustedSymbol];
152152
}
153153

0 commit comments

Comments
 (0)