TypeError: Converting circular structure to JSON


I keep getting this error, anyway to properly debug? The detailed error I’m getting is just general DDP error:

Your app is crashing. Here's the latest log.

=> Meteor server restarted

TypeError: Converting circular structure to JSON
    at Object.stringify (native)
    at stringifyDDP (packages/ddp/livedata_common.js:163:1)
    at [object Object]._.extend.send (packages/ddp/livedata_server.js:464:1)
    at [object Object]._.extend.protocol_handlers.method (packages/ddp/livedata_server.js:666:1)
    at packages/ddp/livedata_server.js:546:1
Exited with code: 8
Your application is crashing. Waiting for file change.


So I’m guessing that something in your collection/pubsub has a circular reference which is becoming apparent when the document(s) is(are) being serialized for DDP.

From the SO post a circular reference is this sort of thing:

var a = {};
a.b = a;


Is there any point this normally happens? Serialization for DDP.


Not sure what you’re asking here, but the DDP specification may be of some help.


The problem appears to likely be that you have set up some data in a way that it has circular references and thus Meteor is not able to properly serialize it and send it across the wire.

The solution then would be to figure out what data you are trying to send and why it has circular references in it and remove those or at least for the purpose of sending the data over the wire transform it into a form without those references and potentially put things back together on the client side as you need them, if you require the CRs there to be intact as well.