MongoDB restart puts Meteor app into broken state, needs restart

When Meteor uses a MongoDB configured by MONGO_URL, Meteor breaks when that MongoDB is restarted. However, the MongoDB that Meteor starts in dev mode can be restarted and everything keeps working. What’s up with that? Does Meteor use a different drivers or something?

This is a real pain in a production environment. If you restart Mongo, you need to restart all the Meteor apps that feed off of it. If somehow Meteor looses it’s connection to Mongo (network connectivity issues, etc), that Meteor is then broken and needs to be restarted.

I tested all of this with the Todo example app. Both a Meteor built app (meteor build …) and dev mode with MONGO_URL have this problem. Plain dev mode with a managed Mongo doesn’t (I tested by just killing the Mongo process - Meteor then restarts it).

Any ideas?

I thought adding “?autoReconnect=true” to the URL might solve this, but no luck. It seems that is already the default, as per issue https://github.com/meteor/meteor/issues/425. I think this issue needs to be re-opened?

Here’s a strange result:

Start a Meteor in dev mode with a managed Mongo. Then start a second dev Meteor with a MONGO_URL pointing to the first (mongodb://localhost:3001/meteor). The first Meteor should survive a Mongo restart, but the second shouldn’t. The surprise is that they both do???

OK, I figured it out: as soon as your MONGO_URL includes a username and password, Meteor can’t recover if that Mongo is restarted.

I think an issue needs to be filed for this?

Thanks for the investigation work Graeme.
I was having the same problem.

Best regards,
Lars Buur

I filed an issue and did some more digging - see https://github.com/meteor/meteor/issues/4600