Glimpse / Home

Project Glimpse: Node Edition - Spend less time debugging and more time developing.
http://node.getglimpse.com
Other
252 stars 9 forks source link

TypeError: Converting circular structure to JSON at MessageConverter.js:38:43 #129

Open lasergoat opened 7 years ago

lasergoat commented 7 years ago

Hello,

I'm not sure if this is the result of me logging an Axios response object but it causes my app to crash due to a fatal error.

I'm using Axios which apparently uses some circular structure for response objects - so when I log them, my app crashes.

Here's a minimal example using an express server:


if (process.env.NODE_ENV !== 'production') {
    require('@glimpse/glimpse').init();
}

const app       = require("express")();

app.get('/test', function(req, res, next) {
  const obj = {
    a: "foo",
  }
  obj.b = obj; // make a circular reference
  console.log(obj); // try to log it
  res.json({ done: true })
});

let server = app.listen(3000);

This produces the following console output:

{ a: 'foo', b: [Circular] }

^^^ that is from my console.log(obj)

THEN....

/Project/node_modules/@glimpse/glimpse-agent-node/release/messaging/MessageConverter.js:38
        transformedMessage.payload = JSON.stringify(payload);
                                          ^

TypeError: Converting circular structure to JSON
    at Object.stringify (native)
    at MessageConverter.transformMessageForTransit (/Project/node_modules/@glimpse/glimpse-agent-node/release/messaging/MessageConverter.js:38:43)
    at /Project/node_modules/@glimpse/glimpse-agent-node/release/inspectors/ConsoleProxy.js:271:61
    at /Project/node_modules/@glimpse/glimpse-agent-node/release/inspectors/util/StackHelper.js:117:25
    at /Project/node_modules/@glimpse/glimpse-agent-node/release/inspectors/util/StackHelper.js:236:21
    at /Project/node_modules/@glimpse/glimpse-agent-node/release/inspectors/util/StackHelper.js:297:17
    at wrappedCallback (/Project/node_modules/@glimpse/glimpse-agent-node/release/async-track/async-track.js:346:33)
    at tryToString (fs.js:449:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:436:12)

This is something which should be caught. As can be seen, the native buffer just says [Circular] instead of trying to output it.

mike-kaufman commented 7 years ago

Sorry for the delay here. There's a fix coming out for this shortly...