Closed Baldhor closed 10 months ago
Are you sure it doesn't have something to do with "RangeError: Maximum call stack size exceeded" ? I agree having both error messages on 1 sentence is a bit confusing...
@RoadXY It's 100% related.
The console.re client use socket.io to send the "objects" the way they are (it's not just strings!). However it cannot handle circular reference. Anyway in a garbage collected environment, circular references should be avoided! So the problem doesn't belong to socket.io.
I just need to find it to solve it :)
Solved using this trick:
const stringifyCircularJSON = obj => {
const seen = new WeakSet();
return JSON.stringify(obj, (k, v) => {
if (v !== null && typeof v === 'object') {
if (seen.has(v)) return;
seen.add(v);
}
return v;
});
};
let obj = JSON.parse(stringifyCircularJSON(arg));
Since I obtain a deep copy, I can then apply filters on it to remove useless or secret data. Currently only "password" are hidden.
Describe the bug There are a circular reference inside the native api client library. I have no idea where it is but it's easy to observe when tyring to log the client object through consolre.re:
If I detach the connection from the entities, the circular reference seems solved (however, we don't get the events anymore ...). In the code, I don't see a problem: client -> connection client -> entities -> connection There are no obviously circular reference like client -> connection -> entities -> connection -> ...
To Reproduce Just activate consolre.re and log the native api client.
Expected behavior Circular reference are bad :) No failure of the consolre.re api.