Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

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

Open
lasergoat opened this issue Jul 26, 2017 · 1 comment
Assignees
Milestone

Comments

@lasergoat
Copy link

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
Copy link
Contributor

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

@mike-kaufman mike-kaufman added this to the M023 milestone Aug 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants