mirror of
https://github.com/democratic-csi/democratic-csi.git
synced 2026-10-17 23:55:27 +02:00
avoid cyclic issues
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
+2
-1
@@ -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;
|
||||
Reference in New Issue
Block a user