Skip to content

Commit

Permalink
Merge pull request #64 from digi-serve/jh/FixTypeError
Browse files Browse the repository at this point in the history
[fix] TypeError: Do not know how to serialize a BigInt
  • Loading branch information
Hiro-Nakamura committed Dec 14, 2023
2 parents f290b70 + 70d39cf commit 7d79134
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions utils/reqService.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function deCircular(args, o, context, level = 1) {
args.push(
`${context ? context : ""}${
context ? "." : ""
}${k}: ${JSON.stringify(o[k].toObj())}`,
}${k}: ${JSON.stringify(o[k].toObj())}`
);
} else {
if (!o[k].____deCircular) {
Expand All @@ -54,14 +54,14 @@ function deCircular(args, o, context, level = 1) {
args,
o[k],
(context ? context + "->" : "") + k,
level + 1,
level + 1
);
}
}
} else {
if (typeof o[k] != "function") {
args.push(
`${context ? context : ""}${context ? "." : ""}${k}: ${o[k]}`,
`${context ? context : ""}${context ? "." : ""}${k}: ${o[k]}`
);
}
}
Expand Down Expand Up @@ -328,7 +328,7 @@ class ABRequestService extends EventEmitter {
return;
}
resolve();
},
}
);
});
};
Expand Down Expand Up @@ -373,7 +373,7 @@ class ABRequestService extends EventEmitter {
return;
}
resolve();
},
}
);
});
};
Expand Down Expand Up @@ -420,7 +420,7 @@ class ABRequestService extends EventEmitter {
return;
}
resolve();
},
}
);
});
};
Expand Down Expand Up @@ -527,7 +527,12 @@ class ABRequestService extends EventEmitter {
var args = [];
allArgs.forEach((a) => {
try {
args.push(JSON.stringify(a));
args.push(
// FIX: TypeError: Do not know how to serialize a BigInt
JSON.stringify(a, (key, value) =>
typeof value === "bigint" ? value.toString() + "n" : value
)
);
} catch (e) {
if (e.toString().indexOf("circular") > -1) {
// var errStack = new Error(
Expand Down Expand Up @@ -692,7 +697,7 @@ class ABRequestService extends EventEmitter {
let tenantDB = this.tenantDB();
if (tenantDB == "") {
let errorNoTenant = new Error(
`Unable to find tenant information for tenantID[${this.tenantID()}]`,
`Unable to find tenant information for tenantID[${this.tenantID()}]`
);
errorNoTenant.code = "ENOTENANT";
reject(errorNoTenant);
Expand Down Expand Up @@ -869,7 +874,7 @@ class ABRequestService extends EventEmitter {
jobID: `ABFactory(${this._tenantID})`,
tenantID: this._tenantID,
},
this.controller,
this.controller
);
ABReq._DBConn = this._DBConn;
ABReq._Model = this._Model;
Expand All @@ -885,7 +890,7 @@ class ABRequestService extends EventEmitter {
["jobID", "_tenantID", "_user", "_userReal", "serviceKey"].forEach(
(f) => {
obj[f] = this[f];
},
}
);
return obj;
}
Expand Down

0 comments on commit 7d79134

Please sign in to comment.