Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoClient.connect doesn't throw error on connection failure #170

Closed
sincerekamal opened this issue Jun 10, 2015 · 4 comments
Closed

MongoClient.connect doesn't throw error on connection failure #170

sincerekamal opened this issue Jun 10, 2015 · 4 comments
Milestone

Comments

@sincerekamal
Copy link

Hi,
I'm just trying to connect to MongoDB using MongoSkin's MongoClient.connect(url) when the DB is not running, but it doesn't throw any error. I couldn't able to find any docs for listening to connection failure.

var mongo = require('mongoskin');
try {
 var db = mongo.MongoClient.connect(mongo.url)
} catch(e) {
   console.log(e);
}
@matteocontrini
Copy link

Yeah, how can we handle connection errors?

@vkarpov15
Copy link
Contributor

@matteocontrini
Copy link

And what about this syntax? It's not documented.

var mongo = require('mongoskin');
var db = mongo.db(connectionString);

@vkarpov15 vkarpov15 added this to the 1.4.14 milestone Jul 9, 2015
@ghost
Copy link

ghost commented Aug 16, 2016

What's the proper approach/method for this? The callback doesn't have any effect when used:

_db = MongoClient.connect(config.mongo, function (err, db) {
    //CHECK ERRORS NEVER CALLED!!!
});

Nor do I see anywhere in the source for any EventEmitter usages indicating errors, only success/open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants