Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

post save handler causes exception #11

Open
jorisroling opened this Issue Jul 9, 2013 · 4 comments

Comments

Projects
None yet
2 participants

I don't know why, but if I put a post save handler on my schema, like this

TeamSchema.post('save', function (doc) {
  console.log('JJR %s has been saved', doc._id);
})

I get a exception (when an actual PUT is precessed) with this stack trace:

/Users/joris/Development/App/Node/www/node_modules/mongoose/lib/utils.js:419
throw err;
^
TypeError: Cannot set property 'code' of null
at .extend (/Users/joris/Development/App/Node/www/node_modules/mers/node_modules/underscore/underscore.js:791:21)
at Array.forEach (native)
at .each..forEach (/Users/joris/Development/App/Node/www/node_modules/mers/node_modules/underscore/underscore.js:79:11)
at Function.
.extend (/Users/joris/Development/App/Node/www/node_modules/mers/node_modules/underscore/underscore.js:788:5)
at Promise.module.exports.router.del.m.findOneAndRemove.res.send.status (/Users/joris/Development/App/Node/www/node_modules/mers/lib/routes.js:113:16)
at Promise.onResolve (/Users/joris/Development/App/Node/www/node_modules/mongoose/node_modules/mpromise/lib/promise.js:162:8)
at Promise.EventEmitter.emit (events.js:96:17)
at Promise.emit (/Users/joris/Development/App/Node/www/node_modules/mongoose/node_modules/mpromise/lib/promise.js:79:38)
at Promise.fulfill (/Users/joris/Development/App/Node/www/node_modules/mongoose/n9 Jul 16:20:26 - [nodemon] app crashed - waiting for file changes before

It boils down to routes.js line 113 where a null obj (returned from the findOne function) is handed to _underscore (_u.extend).

Any idea?

Regards,
Joris

Owner

jspears commented Jul 9, 2013

Is this the code from trunk? If so I may have broken something trying to
get nested posts to work a couple nights ago, and will sort it out
tomorrow, if its from the last version I'll take a closer look.

On Tue, Jul 9, 2013 at 10:39 AM, Joris Röling notifications@github.comwrote:

I don't know why, but if I put a post save handler on my schema, like
this

TeamSchema.post('save', function (doc) {
console.log('JJR %s has been saved', doc._id);})

I get a exception with this stack trace:

/Users/joris/Development/App/Node/www/node_modules/mongoose/lib/utils.js:419
throw err;
^
TypeError: Cannot set property 'code' of null
at .extend
(/Users/joris/Development/App/Node/www/node_modules/mers/node_modules/underscore/underscore.js:791:21)
at Array.forEach (native)
at .each..forEach
(/Users/joris/Development/App/Node/www/node_modules/mers/node_modules/underscore/underscore.js:79:11)
at Function.
.extend
(/Users/joris/Development/App/Node/www/node_modules/mers/node_modules/underscore/underscore.js:788:5)
at Promise.module.exports.router.del.m.findOneAndRemove.res.send.status
(/Users/joris/Development/App/Node/www/node_modules/mers/lib/routes.js:113:16)
at Promise.onResolve
(/Users/joris/Development/App/Node/www/node_modules/mongoose/node_modules/mpromise/lib/promise.js:162:8)
at Promise.EventEmitter.emit (events.js:96:17)
at Promise.emit
(/Users/joris/Development/App/Node/www/node_modules/mongoose/node_modules/mpromise/lib/promise.js:79:38)
at Promise.fulfill
(/Users/joris/Development/App/Node/www/node_modules/mongoose/n9 Jul
16:20:26 - [nodemon] app crashed - waiting for file changes before

It boils down to routes.js line 113 where a null obj (returned from
the findOne function) is handed to _underscore (_u.extend).

Any idea?

Regards,
Joris


Reply to this email directly or view it on GitHubhttps://github.com/jspears/mers/issues/11
.

I got it via npm

mers@0.6.2-0
underscore@1.5.1

I'm happy to use the github (master) version here, should I?

Regards,
Joris

Owner

jspears commented Jul 9, 2013

You can but I wouldn't a few things in there not as tested as I would like.
I will take a look tonight and see if I can do something.

Sent from my iPhone

On Jul 9, 2013, at 11:04 AM, "Joris Röling" notifications@github.com
wrote:

I got it via npm

mers@0.6.2-0
underscore@1.5.1

I'm happy to use the github (master) version here, should I?

Regards,
Joris


Reply to this email directly or view it on
GitHubhttps://github.com/jspears/mers/issues/11#issuecomment-20680250
.

Cheers, Justin!
Joris Röling Bonboa
+31 6 53342115 Noorderplantsoen
joris@bonboa.com Grachtstraat 62
www.bonboa.com 9717 HL Groningen
On Jul 9, 2013, at 17:06, Justin notifications@github.com wrote:

You can but I wouldn't a few things in there not as tested as I would like.
I will take a look tonight and see if I can do something.

Sent from my iPhone

On Jul 9, 2013, at 11:04 AM, "Joris Röling" notifications@github.com
wrote:

I got it via npm

mers@0.6.2-0
underscore@1.5.1

I'm happy to use the github (master) version here, should I?

Regards,
Joris


Reply to this email directly or view it on
GitHubhttps://github.com/jspears/mers/issues/11#issuecomment-20680250
.

Reply to this email directly or view it on GitHub.

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