Browser/client can't validate Mongoose document object when in callback response #9

Open
paulshapiro opened this Issue Nov 18, 2011 · 1 comment

Comments

Projects
None yet
2 participants

I get this in Safari 5.1.1

TypeError: 'undefined' is not an object (evaluating 'Object.propertyIsEnumerable.call(d,f)') dnode.js:1

and this in Chrome:

Uncaught TypeError: Cannot convert null to object
require.modules.events.a.emitdnode.js:1
require.modules./node_modules/dnode-protocol/index.js.f.Session.d.parsednode.js:1
require.modules./node_modules/socket.io-client/dist/browserify.js.c.emitdnode.js:1
require.modules./node_modules/socket.io-client/dist/browserify.js.c.onPacketdnode.js:1
require.modules./node_modules/socket.io-client/dist/browserify.js.d.onPacketdnode.js:1
require.modules./node_modules/socket.io-client/dist/browserify.js.c.onPacketdnode.js:1
require.modules./node_modules/socket.io-client/dist/browserify.js.c.onDatadnode.js:1
require.modules./node_modules/socket.io-client/dist/browserify.js.d.open.websocket.onmessage

When I run the object through JSON.parse(JSON.stringify(...)) the browser receives it without issue.

I'm using MongooseJS and I get the object by going something like this

Model.findById(id).run(function(err, obj) { .... })

Inside, I replace the object with the result of calling .toObject() on itself and then I fetch some of its children (which fetch their children) which I also replace with themselves.toObject().

One last piece of information is that I'm porting the app in which this takes place from NowJS to dnode and the response object worked in NowJS.

+1'ing this issue.

Mongoose does create a funky looking object, with multiple depths of inheritance and a bunch of magic, but I'm thinking that dnode should maybe handle that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment