mongodbmeteormeteor-up

Meteor app crash randomly throwing a 'MongoError: server instance pool was destroyed' error


I deployed a meteor app to an AWS server using mup which used docker to deploy the app. I also used mLab sandboxed db.

The issue is, the app crashes without warning after some time. Crashing means the app still works but data won't load from the database. I have two versions of the app (staging and production) running in two different servers. But both have this issue. In the docker logs I see this error repeated a lot of times :

Exception in setInterval callback: MongoError: server instance pool was destroyed
    at Object.Future.wait (/bundle/bundle/programs/server/node_modules/fibers/future.js:446:16)
    at MongoConnection.<anonymous> (packages/meteor/helpers.js:119:1)
    at MongoConnection.(anonymous function) [as update] (packages/mongo/mongo_driver.js:771:49)
    at [object Object].update (packages/mongo/collection.js:589:29)
    at AccountsServer.Ap._expireTokens (packages/accounts-base/accounts_server.js:1100:14)
    at packages/accounts-base/accounts_server.js:1173:14
    at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
    at packages/meteor/timers.js:6:1
    at runWithEnvironment (packages/meteor/dynamics_nodejs.js:110:1)
    - - - - -
    at Function.MongoError.create (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/error.js:29:11)
    at basicWriteValidations (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:433:51)
    at [object Object].Server.update (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:543:16)
    at [object Object].Server.update (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/server.js:386:17)
    at updateDocuments (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/collection.js:1037:19)
    at [object Object].Collection.update (/bundle/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/collection.js:1075:44)
    at MongoConnection._update (packages/mongo/mongo_driver.js:560:18)
    at MongoConnection.<anonymous> (packages/meteor/helpers.js:118:1)
    at MongoConnection.(anonymous function) [as update] (packages/mongo/mongo_driver.js:771:49)
    at [object Object].update (packages/mongo/collection.js:589:29)

Any idea what's happening?

In the client browser console, I see this error:

WebSocket connection to 'wss://oursite.com/sockjs/373/2lrpal10/websocket' failed: WebSocket is closed before the connection is established.


Solution

  • Updating npm-mongo and mongo fixed this for me.

    meteor update --all-packages