Describe the bug
Node.js version: v16.14.0
OS version: Ubuntu 18.04.6 LTS
Description:
When attempting to send a POST request with a payload that contains a BigInt value, the JSON serialization silently fails and proceeds with the post request using a POST body set to: "[unable to serialize, circular reference is too complex to analyze]"
NOTE: I have not tested or checked if other serialization issues (ex: an actual circular reference) also have this same behaviour, but I imagine they very likely could.
Actual behavior
Superagent fails to serialize the BigInt to JSON, but instead of throwing an error, it simply continues to processes the POST request with the POST body set to: "[unable to serialize, circular reference is too complex to analyze]"
Expected behavior
Ideally, superagent would properly handle BigInt numbers... but at the very least it should:
- throw an exception when it fails to serialize data, and
- have an error message that is more accurate to the issue (ex: "Cannot serialize BigInt value" rather than a confusing message about circular references).
Code to reproduce
const superagent = require("superagent");
const data = {
number: BigInt("1")
};
superagent
.post("https://httpbin.org/post")
.send(data)
.end((err, res) => {
console.log("ERROR:", err);
console.log("POST BODY SENT TO SERVER:", res.body.data);
});
Result:
ERROR: null
POST BODY SENT TO SERVER: "[unable to serialize, circular reference is too complex to analyze]"
Checklist
Describe the bug
Node.js version: v16.14.0
OS version: Ubuntu 18.04.6 LTS
Description:
When attempting to send a POST request with a payload that contains a
BigIntvalue, the JSON serialization silently fails and proceeds with the post request using a POST body set to:"[unable to serialize, circular reference is too complex to analyze]"NOTE: I have not tested or checked if other serialization issues (ex: an actual circular reference) also have this same behaviour, but I imagine they very likely could.
Actual behavior
Superagent fails to serialize the
BigIntto JSON, but instead of throwing an error, it simply continues to processes the POST request with the POST body set to: "[unable to serialize, circular reference is too complex to analyze]"Expected behavior
Ideally,
superagentwould properly handleBigIntnumbers... but at the very least it should:Code to reproduce
Result:
Checklist