avoid cyclic issues
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
parent
b723136f2a
commit
a18f8ad8b7
|
|
@ -3,6 +3,7 @@
|
|||
const yaml = require("js-yaml");
|
||||
const fs = require("fs");
|
||||
const { grpc } = require("../src/utils/grpc");
|
||||
const { stringify } = require("../src/utils/general");
|
||||
|
||||
let options;
|
||||
const args = require("yargs")
|
||||
|
|
@ -127,7 +128,7 @@ try {
|
|||
let operationLock = new Set();
|
||||
|
||||
async function requestHandlerProxy(call, callback, serviceMethodName) {
|
||||
const cleansedCall = JSON.parse(JSON.stringify(call));
|
||||
const cleansedCall = JSON.parse(stringify(call));
|
||||
for (const key in cleansedCall.request) {
|
||||
if (key.includes("secret")) {
|
||||
cleansedCall.request[key] = "redacted";
|
||||
|
|
|
|||
|
|
@ -51,6 +51,24 @@ function getLargestNumber() {
|
|||
return number;
|
||||
}
|
||||
|
||||
function stringify(value) {
|
||||
const getCircularReplacer = () => {
|
||||
const seen = new WeakSet();
|
||||
return (key, value) => {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
if (seen.has(value)) {
|
||||
return;
|
||||
}
|
||||
seen.add(value);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
};
|
||||
|
||||
return JSON.stringify(value, getCircularReplacer());
|
||||
}
|
||||
|
||||
module.exports.sleep = sleep;
|
||||
module.exports.lockKeysFromRequest = lockKeysFromRequest;
|
||||
module.exports.getLargestNumber = getLargestNumber;
|
||||
module.exports.stringify = stringify;
|
||||
Loading…
Reference in New Issue