Heroku app crashes after MongoDB updated to 3.0
Asked Answered
H

2

5

MongoDB just forced an update on my Heroku server today from 2.6 to 3.0

Now my app crashes shortly after startup with the error:

2015-10-01T10:22:27.405579+00:00 heroku[web.1]: State changed from crashed to starting
2015-10-01T10:22:42.457971+00:00 heroku[web.1]: Starting process with command `node server`
2015-10-01T10:22:46.278159+00:00 app[web.1]: memory, and will not scale past a single process.
2015-10-01T10:22:46.278136+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2015-10-01T10:22:46.278157+00:00 app[web.1]: designed for a production environment, as it will leak
2015-10-01T10:22:47.151118+00:00 app[web.1]: production server running at http://localhost:33827
2015-10-01T10:22:47.463775+00:00 heroku[web.1]: State changed from starting to up
2015-10-01T10:22:47.767430+00:00 app[web.1]: /app/node_modules/mongodb/lib/mongodb/connection/base.js:246
2015-10-01T10:22:47.767437+00:00 app[web.1]:         throw message;
2015-10-01T10:22:47.767439+00:00 app[web.1]:               ^
2015-10-01T10:22:47.767441+00:00 app[web.1]: MongoError: auth failed
2015-10-01T10:22:47.767443+00:00 app[web.1]:     at Object.toError (/app/node_modules/mongodb/lib/mongodb/utils.js:114:11)
2015-10-01T10:22:47.767444+00:00 app[web.1]:     at /app/node_modules/mongodb/lib/mongodb/db.js:1156:31
2015-10-01T10:22:47.767445+00:00 app[web.1]:     at /app/node_modules/mongodb/lib/mongodb/db.js:1890:9
2015-10-01T10:22:47.767447+00:00 app[web.1]:     at Server.Base._callHandler (/app/node_modules/mongodb/lib/mongodb/connection/base.js:448:41)
2015-10-01T10:22:47.767449+00:00 app[web.1]:     at /app/node_modules/mongodb/lib/mongodb/connection/server.js:481:18
2015-10-01T10:22:47.767450+00:00 app[web.1]:     at MongoReply.parseBody (/app/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
2015-10-01T10:22:47.767452+00:00 app[web.1]:     at null.<anonymous> (/app/node_modules/mongodb/lib/mongodb/connection/server.js:439:20)
2015-10-01T10:22:47.767453+00:00 app[web.1]:     at emit (events.js:107:17)
2015-10-01T10:22:47.767455+00:00 app[web.1]:     at null.<anonymous> (/app/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:201:13)
2015-10-01T10:22:47.767456+00:00 app[web.1]:     at emit (events.js:110:17)
2015-10-01T10:22:47.767458+00:00 app[web.1]:     at Socket.<anonymous> (/app/node_modules/mongodb/lib/mongodb/connection/connection.js:439:22)
2015-10-01T10:22:47.767459+00:00 app[web.1]:     at Socket.emit (events.js:107:17)
2015-10-01T10:22:47.767461+00:00 app[web.1]:     at readableAddChunk (_stream_readable.js:163:16)
2015-10-01T10:22:47.767462+00:00 app[web.1]:     at Socket.Readable.push (_stream_readable.js:126:10)
2015-10-01T10:22:47.767463+00:00 app[web.1]:     at TCP.onread (net.js:538:20)
2015-10-01T10:22:48.687613+00:00 heroku[web.1]: Process exited with status 1
2015-10-01T10:22:48.704259+00:00 heroku[web.1]: State changed from up to crashed

I checked their status page, and found that Mongo had updated their servers to version 3.0, but also that the update should be stable now, and thus is something I need to do on my end.

After looking a bit more into it. I figured out that I'm supposed to install new "drivers" to be compatible with version 3.0.

I found this link http://docs.mongodb.org/manual/release-notes/3.0-scram/#upgrade-drivers

But it doesn't describe how exactly I can go about updating the drivers on my Heroku app.

I'm using their sandbox servers.

I tried contacting their support but they just gave me the same link.

I contacted Heroku support as well. But all they said is:

You need to make sure that the libraries you are using for Mongo support the new version 3.0 of Mongo. It's not necessarily a 'driver' as such

Which doesn't help me either.

Here's the contents of my package.json if that helps.

{
  "name": "Stocks",
  "private": true,
  "version": "0.0.1",
  "main": "server.js",
  "engines": {
    "node": "0.12.x",
    "npm": "*"
  },
  "author": "Anom <[email protected]",
  "dependencies": {
    "aws-sdk": "*",
    "body-parser": "^1.10.1",
    "connect": "^3.3.5",
    "connect-flash": "^0.1.1",
    "ejs": "^2.2.1",
    "express": "^4.11.0",
    "express-session": "^1.10.1",
    "forever": "*",
    "grunt": "^0.4.5",
    "grunt-cli": "^0.1.13",
    "grunt-contrib-jshint": "^0.11.2",
    "grunt-contrib-sass": "^0.9.2",
    "grunt-contrib-uglify": "^0.8.1",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-express-server": "^0.5.1",
    "grunt-ssh": "^0.12.3",
    "gulp": "latest",
    "mongoose": "3.8.19",
    "multer": "^0.1.8",
    "node-sass": "^2.1.1",
    "nodemailer": "^1.3.4",
    "passport": "^0.2.1",
    "passport-local": "^1.0.0",
    "postmark": "^1.0.0",
    "request": "^2.55.0",
    "stripe": "^3.3.4"
  },
  "devDependencies": {},
  "scripts": {
    "start": "node server"
  }
}

Any help to figure out how I can update drivers on my Heroku app to be compatible with the new 3.0 MongoDB would be greatly appreciated.

Hesione answered 1/10, 2015 at 11:46 Comment(8)
npm install mongodb mongoose connect-mongo?Contemplate
I don't have a development environment set up on this computer. All I got is the git-environment, which I can push to make changes.Hesione
I meant to run those on heroku server. may be you just update package.json to use latest mongodb and push to heroku. may be its done automatically, but I dont really know.Contemplate
How do you run those on the Heroku server? Or update what exactly in my package.json, I can't see the "drivers" mentioned in there anywhere.Hesione
heroku run ... something? or push updated package.json to server with git push heroku master? but I am not heroku expert.Contemplate
MongoDB is added using a Heroku Addon. Not using a command. I'm not sure how safe it would be to run that on the server when it wasn't installed that way? I added the contents of my package.json though, if that helps any?Hesione
looks like mongodb need to upgrade - github.com/Automattic/mongoose/issues/3144Contemplate
yeah but how do I update this on Heroku?Hesione
L
10

You're using mongoose 3.8.19. The latest version of mongoose is 4.1.9. I would start there:

$ npm install --save --save-exact [email protected]
Logician answered 1/10, 2015 at 16:10 Comment(3)
I got my site back up and running now. I didn't do this exact thing. But I realized mongoose was the "driver" / library. the Support team has been refering to... And I changed the version of it to 4.1.9 in my package.json, after pushing that, the site now works. It seems a bit slower than usual. But it works. If you want to edit your answer, adding the package.json change in there. Then I can accept it. Thanks for the help!Hesione
The --save flag does the package.json change for you.Logician
oh. Didn't know that. Accepted the answer :) Thanks!Hesione
P
1

I had the exact same problem I did all of the above and nothing worked. Only until I deleted mongoose out of my package.json and reinstalled it thats when it worked

Parfitt answered 3/10, 2015 at 10:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.