mongodb/node-mongodb-native — pull request #890 by natesilva (2013-02-21 01:52:12+00:00)
Title: Make Db.connect close the connection on error and return null

The callback for `Db.connect` is [documented](http://mongodb.github.com/node-mongodb-native/api-generated/db.html#db-connect) to return `null` as the second parameter if an error occurred.

In fact, if there was an authentication failure, it was returning *both* an error object and a live db instance. This would cause Node.js to hang on exit because of the db connection that was never closed.

This bug was causing a hang in `MongoClient.connect`.