Skip to content

Commit e1004d3

Browse files
v2.0.3: bugfix
1 parent 571a24d commit e1004d3

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/helpers.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ exports.prepareMetaData = meta=>{
1919
// through cycling properties and `common.clone` doesn't copies them
2020
return {message: meta.message, name: meta.name, stack: meta.stack};
2121
}
22-
meta = common.clone(meta);
2322
if (typeof meta === 'object' && meta !== null) {
24-
makeObjectNonCircular(meta);
23+
meta = makeObjectNonCircular(meta);
2524
cleanFieldNames(meta);
2625
}
26+
meta = common.clone(meta);
2727
return meta;
2828
};
2929

@@ -58,18 +58,22 @@ function cleanFieldNames(object) {
5858
function makeObjectNonCircular(node, opt_parents) {
5959
opt_parents = opt_parents || [];
6060
opt_parents.push(node);
61+
let copy = {};
6162
for (let key in node) {
6263
if (!Object.prototype.hasOwnProperty.call(node, key)) {
6364
continue;
6465
}
6566
let value = node[key];
6667
if (typeof value === 'object') {
6768
if (opt_parents.indexOf(value) === -1) {
68-
makeObjectNonCircular(value, opt_parents);
69+
copy[key] = makeObjectNonCircular(value, opt_parents);
6970
} else {
70-
node[key] = '[Circular]';
71+
copy[key] = '[Circular]';
7172
}
73+
} else {
74+
copy[key] = value;
7275
}
7376
}
7477
opt_parents.pop();
78+
return copy;
7579
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "winston-mongodb",
33
"license": "MIT",
4-
"version": "2.0.2",
4+
"version": "2.0.3",
55
"description": "A MongoDB transport for winston",
66
"author": "Charlie Robbins <[email protected]>",
77
"contributors": [

0 commit comments

Comments
 (0)