TypeError: Converting circular structure to JSON


#1

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

/Users/michaelevensen/.meteor/packages/meteor-tool/.1.1.3.r7q9f4++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
						throw(ex);
						      ^
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.

#2

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;

#3

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


#4

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


#5

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.