Mongoose Save is not Firing Callback

697 views
Skip to first unread message

Chris Andrejewski

unread,
May 13, 2013, 9:13:17 PM5/13/13
to mongoo...@googlegroups.com
I am working on a Node application that does use multiple Mongoose database connections at once. I am separating the models set to each connection correctly and I am not saving any of the models in any parallel way that I could mess up. But I am getting a very strange result from Mongoose when it saves my model instance. 

The line that kills:

> Model.create(data, function(err, model) {...})

[I have written this in the shorthand method, but any way I try to write it, I get the exact same problem regardless.]

The result I get:
The model IS saved to the database exactly as you would expect; I can open `mongo`, navigate to the db, and the model instance's data will be there. But inside of my JavaScript, the internal save() method is not calling the callback I have supplied it. I have looked at all of my code: the connection is correct (because the data is being saved correctly), the callback is a function (I wrapped it in a closure that returns it as a function and I know it is a function), the data being saved is correct (so says the DB and console.log), my schema with provided data validates correctly (I ran the model instance through the #validate method and err was undefined). I have no idea what the problem could be.

I have looked online at every resource that deals with this problem (and the StackOverflow questions answered on the subject). I have found no solution.

Worst Case Scenario: I'll have to use the hacky setTimeout method of waiting for the model to be saved to the DB and then, since it does actually save, I will have to find it via querying and work with the instance from there. There is a lot of headway and potholes in that option, please help me resolve this problem.

Aaron Heckmann

unread,
May 15, 2013, 11:13:32 AM5/15/13
to mongoo...@googlegroups.com
Code? Mongoose version? Node version? MongoDB version?
--
Documentation - http://mongoosejs.com/
Plugins - http://plugins.mongoosejs.com/
Bug Reports - http://github.com/learnboost/mongoose
Production Examples - http://mongoosejs.tumblr.com/
StackOverflow - http://stackoverflow.com/questions/tagged/mongoose
Google Groups - https://groups.google.com/forum/?fromgroups#!forum/mongoose-orm
Twitter - https://twitter.com/mongoosejs
IRC - #mongoosejs
---
You received this message because you are subscribed to the Google Groups "Mongoose Node.JS ODM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
Aaron



Chris Andrejewski

unread,
May 15, 2013, 10:29:46 PM5/15/13
to mongoo...@googlegroups.com
Code Attached. Mongoose version is the latest release, 3.6.8. Node version is v0.8.12. MongoDB version is 2.2.3.

For context's sake, the code is part of an express (connect) application. The function containing the problematic function is a router handle function called 'signup'. Since my original post I have updated all of my Node modules and have tried the function multiple times on different MongoDB databases, nothing has changed. 
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
Aaron



user.js
mong-bug-stub.js

Chris Andrejewski

unread,
May 21, 2013, 2:37:15 PM5/21/13
to mongoo...@googlegroups.com
Does anyone know what the problem is?

Aaron Heckmann

unread,
May 22, 2013, 2:45:06 PM5/22/13
to mongoo...@googlegroups.com
Not sure what I need to run this script. Can you remove everything except mongoose so we can more easily track down the issue?


To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Chris Andrejewski

unread,
May 22, 2013, 11:11:10 PM5/22/13
to mongoo...@googlegroups.com
The model is the same. The mong-bug-stub.js is re-written and has no dependencies. I am starting to think there is a problem in the model causing some conflict because the stub looks fine.
mong-bug-stub.js

Aaron Heckmann

unread,
May 23, 2013, 5:42:22 PM5/23/13
to mongoo...@googlegroups.com
This doesn't run for me. Please create a single runnable test file.

Chris Andrejewski

unread,
May 23, 2013, 7:53:47 PM5/23/13
to mongoo...@googlegroups.com
Here you go
mong-bug-stub.js

Aaron Heckmann

unread,
Jun 3, 2013, 5:31:25 PM6/3/13
to mongoo...@googlegroups.com
Still cannot reproduce. Is there anything I need?
Reply all
Reply to author
Forward
0 new messages