Closed qharlie closed 12 years ago
If you have no control over your code throwing an exception you'll need to add a try/catch block. If you're merely debugging, you'll want to consider using the uncaughtException feature of node.js: http://nodejs.org/api/process.html#process_event_uncaughtexception
That way you can at least print out the exception when it happens.
But why are they getting swallowed? Exceptions everywhere else in my node code prints out a stack trace and an error ?
+1 it causes assertion failures to silently get swallowed when testing :-(
These are actually getting swallowed by mongodb, in line 310 of connection.js , it then emits a parseError if it finds an exception in the callback.
Maybe mongolian listens for a parseError and rethrows the error ?
In case you didn't get my email, adding
connection.on('parseError', function(error)
{
throw error.trace;
});
To MongolianServer() in server.js fixes the problem for me.
I'm not at my computer but it sounds like you're using an old version of Mongolian. The latest doesn't depend on mongodb and doesn't have that limitation (that annoyance was one of the many reasons I decided to remove the dependency).
Marcello
On Mar 12, 2012, at 7:03 PM, charles sandersreply@reply.github.com wrote:
In case you didn't get my email, adding
connection.on('parseError', function(error) { throw error.trace; });
To MongolianServer() in server.js fixes the problem for me.
Reply to this email directly or view it on GitHub: https://github.com/marcello3d/node-mongolian/issues/93#issuecomment-4465513
I can't seem to reproduce this with the latest mongolian.
Here's my slightly modified test code:
var Mongolian = require('mongolian')
var server = new Mongolian
var db = server.db('mongolian_test')
var collection = db.collection('templates')
collection.find({}).skip(0).sort({'_id': 1}).limit(10).toArray(function (err, value) {
if (err) {
console.log("Dao error = ", err);
}
else {
console.log("value="+value);
someFuncThatDoesntExists();
console.log("HERE!");
}
})
And its output (minus the mongolian debug logging—note that I don't actually have anything in the collection):
value=
~/workspace/test/test.js:11
someFuncThatDoesntExists();
^
ReferenceError: someFuncThatDoesntExists is not defined
at ~/workspace/test/test.js:11:9
at ~/workspace/test/node_modules/mongolian/lib/cursor.js:208:13
at ~/workspace/test/node_modules/mongolian/lib/util.js:19:13
at [object Object].nextBatch (~/workspace/test/node_modules/mongolian/lib/cursor.js:153:9)
at ~/workspace/test/node_modules/mongolian/lib/cursor.js:205:18
at ~/workspace/test/node_modules/mongolian/lib/util.js:19:13
at ~/workspace/test/node_modules/mongolian/lib/cursor.js:125:9
at ~/workspace/test/node_modules/mongolian/lib/util.js:19:13
at Connection.<anonymous> (~/workspace/test/node_modules/mongolian/lib/server.js:233:17)
at Connection.emit (events.js:67:17)
Closing due because I can't reproduce. I can reopen it if you still have trouble.
When the below executes, I never get to see 'HERE!', it just silently fails and doesn't give me any errors. How can I get runtime errors from within my callbacks ?
var server = new Mongolian({ host: 'mongodb-server', port: 27017}); var db = server.db('core'); var collection = db.collection('templates'); collection.find({}).skip(0).sort({'_id': 1}).limit(10).toArray(function (err, value) {
});