You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Exception in callback of async function: Error: failed to connect to [127.0.0.1:27017]
at null.<anonymous> (/Users/pward/.meteor/packages/mongo/.220.127.116.11kr7rhx++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/server.js:536:74)
at emit (events.js:106:17)
at null.<anonymous> (/Users/pward/.meteor/packages/mongo/.18.104.22.168kr7rhx++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
at emit (events.js:98:17)
at Socket.<anonymous> (/Users/pward/.meteor/packages/mongo/.22.214.171.124kr7rhx++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/connection.js:516:10)
at Socket.emit (events.js:95:17)
at process._tickCallback (node.js:419:13)
The text was updated successfully, but these errors were encountered:
Meteor apps that use the mongo package generally expect to be able to connect to Mongo at startup and crash the server otherwise (and should be run in a standard environment that knows how to deal with crashing processes). If your server is NOT crashing, that would be be concerning. Otherwise, it is working as intended.
My app is currently running in a docker container and uses systemd to keep the container running. The server is NOT crashing. Here are the steps you can use to reproduce.
git clone https://github.com/meteor/simple-todos
The above will cause the error message in my original post to be displayed but the app remains running. It's just non-responsive. If you look at MUP, arunoda hacks around this problem by pinging the mongo instance until it's running and then starting the app.
This is actually indicative of a bigger problem (at least where my app is concerned). I can't find the module right now, but I traced it down to a common async callback handler that traps exceptions and just console logs the message then goes on about its business. I'd really like to see an environment switch that will force the app to crash on any unhanded exception inside a callback.
Previously, the MongoConnection constructor (which gets called
implicitly the first time you make a Mongo.Collection) would wait for a
successful connection before returning ... if an oplog URL is supplied.
If not in oplog mode, it would return before the connection is
successful, and the first subsequent calls that actually tried to do
something with the DB would block instead.
Having an inconsistent API that is sometimes sync and sometimes async is
not very clear. Moreover, error handling from connect was strange.
Prior to 0.8.1 (24a0006), connect errors would be thrown
uncatchably (ie, from an unrelated context). Starting with 0.8.1,
connect errors would effectively be ignored due to the new
bindEnvironment (they'd be logged, but all code would continue
It's pretty important that startup connection errors crash the server
process instead of letting it keep running unproductively. And it would
also be nice if those errors could be caught (if you're making a
MongoConnection in your own code). So this change ensures that
connection errors get thrown by the MongoConnection constructor.
Test Plan: new unit test. manual test with MONGO_URL=xxx
Differential Revision: https://phabricator.meteor.io/D19