Mongolab and Mongoose Not connecting [duplicate] - node.js

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 <anom#gmail.com",
"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.

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 mongoose#4.1.9

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

Related

Deploy Node-RED to Heroku

I found out the files included in the Github repo that used to connect to the Heroku server and substituted with my own package.json, flow .json, repo link in app.json. After deploying, I tried opening app and received an error from the logs window of Heroku CLI as below:
2021-04-13T10:22:01.693823+00:00 heroku[web.1]: Starting process with command `node --max-old-space-size=384 node_modules/node-red/red.js --settings ./settings.js --userDir ./`
2021-04-13T10:22:05.304911+00:00 heroku[web.1]: Process exited with status 1
2021-04-13T10:22:05.411606+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-13T10:22:05.185490+00:00 app[web.1]: throw err;
2021-04-13T10:22:05.185491+00:00 app[web.1]: ^
2021-04-13T10:22:05.185491+00:00 app[web.1]:
2021-04-13T10:22:05.185492+00:00 app[web.1]: Error: Cannot find
module '/app/node_modules/node-red/red.js'
2021-04-13T10:22:05.185492+00:00 app[web.1]: at
Function.Module._resolveFilename
(internal/modules/cjs/loader.js:880:15)
2021-04-13T10:22:05.185492+00:00 app[web.1]: at
Function.Module._load (internal/modules/cjs/loader.js:725:27)
2021-04-13T10:22:05.185493+00:00 app[web.1]: at
Function.executeUserEntryPoint [as runMain]
(internal/modules/run_main.js:72:12)
2021-04-13T10:22:05.185494+00:00 app[web.1]: at
internal/main/run_main_module.js:17:47 {
2021-04-13T10:22:05.185494+00:00 app[web.1]: code:
'MODULE_NOT_FOUND',
2021-04-13T10:22:05.185495+00:00 app[web.1]: requireStack: []
2021-04-13T10:22:05.185495+00:00 app[web.1]: }
My Github repo link
Hope to get your help. Thanks.
You have removed Node-RED from the package.json, so since it's not installed it won't start.
{
"name": "node-red-project",
"description": "A Node-RED Project",
"version": "0.0.1",
"dependencies": {
"node-red-contrib-alarm": "~1.2.5",
"node-red-contrib-component-dashboard": "0.0.4",
"node-red-contrib-components": "~0.1.8",
"node-red-contrib-firebase": "~1.1.1",
"node-red-contrib-influxdb": "~0.5.1",
"node-red-contrib-mqtt-broker": "~0.2.4",
"node-red-contrib-remote": "~1.1.3",
"node-red-contrib-ttn": "~2.0.5",
"node-red-contrib-ui-svg": "~2.2.1",
"node-red-contrib-users": "~0.1.9",
"node-red-dashboard": "~2.14.0",
"node-red-node-ui-table": "~0.3.10"
}
}
If you want to add extra nodes, you need to add these to the list of dependencies in the existing package.json not just replace them.
{
"name": "nodered-heroku",
"version": "0.0.7",
"dependencies": {
"when": "3.7.8",
"nano": "8.2.2",
"feedparser":"2.2.10",
"node-red-dashboard":"2.23.3",
"redis":"3.0.2",
"node-red": "1.1.3",
"node-red-node-tail": "0.1.1",
"node-red-contrib-aedes": "0.3.6",
"node-red-contrib-blynk-ws": "1.0.3",
"node-red-node-email": "1.7.9",
"node-red-node-ui-list": "0.3.1",
"node-red-contrib-telegrambot": "8.4.0",
"node-red-contrib-alarm": "~1.2.5",
"node-red-contrib-component-dashboard": "0.0.4",
"node-red-contrib-components": "~0.1.8",
"node-red-contrib-firebase": "~1.1.1",
"node-red-contrib-influxdb": "~0.5.1",
"node-red-contrib-mqtt-broker": "~0.2.4",
"node-red-contrib-remote": "~1.1.3",
"node-red-contrib-ttn": "~2.0.5",
"node-red-contrib-ui-svg": "~2.2.1",
"node-red-contrib-users": "~0.1.9",
"node-red-node-ui-table": "~0.3.10"
}
}
I would also suggest you use the latest version of Node-RED (1.3.1 at time of posting) as 1.1.3 is VERY OLD

Node app segfault on Heroku: std::bad_alloc and exit code 134

I am having difficulty understanding this heroku stack trace. My app has been running very well both locally and in Heroku for a few years now. Yet I am suddenly plagued by immediate crashes on Heroku. Here is the stack trace:
2019-05-14T14:05:14.947049+00:00 heroku[web.1]: Starting process with command `yarn run server`
2019-05-14T14:05:17.599376+00:00 app[web.1]: yarn run v1.16.0
2019-05-14T14:05:17.680344+00:00 app[web.1]: $ babel-node src/server.js
2019-05-14T14:05:20.674637+00:00 app[web.1]: Find the server at: http://localhost:13606/
2019-05-14T14:05:20.992257+00:00 heroku[web.1]: State changed from starting to up
2019-05-14T14:05:21.044128+00:00 app[web.1]: /app/.heroku/node/bin/node[43]: ../src/node_http_parser_impl.h:219:int node::{anonymous}::Parser::on_header_field(const char*, size_t): Assertion `(num_fields_) < (kMaxHeaderFieldsCount)' failed.
2019-05-14T14:05:21.203166+00:00 heroku[web.1]: Process exited with status 134
2019-05-14T14:05:21.044912+00:00 app[web.1]: 1: 0x98c680 node::Abort() [/app/.heroku/node/bin/node]
2019-05-14T14:05:21.045428+00:00 app[web.1]: 2: 0x98c707 [/app/.heroku/node/bin/node]
2019-05-14T14:05:21.045942+00:00 app[web.1]: 3: 0x9a878f [/app/.heroku/node/bin/node]
2019-05-14T14:05:21.046587+00:00 app[web.1]: 4: 0x1845a8a http_parser_execute [/app/.heroku/node/bin/node]
2019-05-14T14:05:21.047108+00:00 app[web.1]: 5: 0x9aaf73 [/app/.heroku/node/bin/node]
2019-05-14T14:05:21.047681+00:00 app[web.1]: 6: 0xb8ed76 [/app/.heroku/node/bin/node]
2019-05-14T14:05:21.048731+00:00 app[web.1]: 7: 0xb90c89 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/app/.heroku/node/bin/node]
2019-05-14T14:05:21.049358+00:00 app[web.1]: 8: 0x1a86142 [/app/.heroku/node/bin/node]
2019-05-14T14:05:21.096170+00:00 app[web.1]: Aborted
2019-05-14T14:05:21.117588+00:00 app[web.1]: error Command failed with exit code 134.
2019-05-14T14:05:21.117924+00:00 app[web.1]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2019-05-14T14:05:21.226349+00:00 heroku[web.1]: State changed from up to crashed
2019-05-14T14:05:21.231860+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-14T14:05:25.403108+00:00 heroku[web.1]: Starting process with command `yarn run server`
2019-05-14T14:05:28.317361+00:00 app[web.1]: yarn run v1.16.0
2019-05-14T14:05:28.378392+00:00 app[web.1]: $ babel-node src/server.js
2019-05-14T14:05:30.597889+00:00 app[web.1]: Find the server at: http://localhost:6669/
2019-05-14T14:05:30.903500+00:00 app[web.1]: terminate called after throwing an instance of 'std::bad_alloc'
2019-05-14T14:05:30.903510+00:00 app[web.1]: what(): std::bad_alloc
2019-05-14T14:05:30.919424+00:00 app[web.1]: Aborted
2019-05-14T14:05:30.937524+00:00 app[web.1]: error Command failed with exit code 134.
Other Notes:
Heroku memory usage is well within quota.
Everything runs fine locally.
My heroku app is linked to a github repo, which I've reverted to a commit pre-crash, yet to no avail.
node_modules/is not tracked.
I've followed these directions to purge the cache.
Here is my package.json:
{
"name": "korah-app",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">8.9.1"
},
"dependencies": {
"await-sleep": "^0.0.1",
"babel-cli": "6.14.0",
"babel-core": "6.14.0",
"body-parser": "^1.17.2",
"body-parser-xml": "^1.1.0",
"bottleneck": "^2.12.1",
"cors": "^2.8.4",
"dotenv": "^4.0.0",
"express": "4.13.3",
"express-xml-bodyparser": "^0.3.0",
"firebase-admin": "^4.1.3",
"fs": "0.0.2",
"heroku-ssl-redirect": "^0.0.4",
"lodash": "^4.17.4",
"moment": "^2.17.1",
"node-schedule": "^1.3.0",
"path": "^0.12.7",
"request": "^2.81.0",
"request-promise": "^4.2.1",
"sql.js": "0.3.2",
"string-similarity": "^1.2.2",
"vhost": "^3.0.2",
"voucher-code-generator": "^1.1.1",
"xml-to-json-promise": "^0.0.3",
"xml2js": "^0.4.17"
},
"scripts": {
"server": "babel-node src/server.js",
"ghb": "babel-node start_client_GHB.js",
"dbw": "babel-node start_client_DBW.js",
"lint": "eslint ."
},
"devDependencies": {
"concurrently": "3.1.0",
"eslint": "3.15.0",
"eslint-config-airbnb": "14.1.0",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "4.0.0",
"eslint-plugin-react": "6.9.0"
}
}
Can someone help me understand how to go about trying to debug this?
Ensuring that my package.json was using the same versions of node and npm as I run locally, solved the mystery for me.
"engines": {
"node": "12.1.0",
"npm": "6.9.0"
},

Deployment to heroku [Error: spawn babel-node ENOENT]

Project works perfectly on dev machine. I've already spent more than 5 hours:
trying out different configurations using bash 'start' scripts on heroku remotely
installing babel-cli and babel-preset-env as dependencies instead of devDependencies
reading through heroku documentation about local builds, trying out
them
disabling dotenv in production
What are your suggestions / solution to this babel-node and heroku incompatibility? Maybe they're disabling it, since it makes more load on their server memory? I've written all my files in ES6 and I tried to rewrite them to old syntax, but that's almost impossible. Is there a way to make babel work on server-side for heroku?
Heroku application log:
2018-05-01T12:08:44.677261+00:00 heroku[web.1]: Starting process with command `npm start`
2018-05-01T12:08:47.873964+00:00 app[web.1]: [heroku-exec] Starting
2018-05-01T12:08:48.920661+00:00 app[web.1]:
2018-05-01T12:08:48.920707+00:00 app[web.1]: > rearn#1.0.0 start /app
2018-05-01T12:08:48.920710+00:00 app[web.1]: > cross-env NODE_ENV=production babel-node server/server.js
2018-05-01T12:08:48.920712+00:00 app[web.1]:
2018-05-01T12:08:49.196690+00:00 app[web.1]: events.js:183
2018-05-01T12:08:49.196703+00:00 app[web.1]: throw er; // Unhandled 'error' event
2018-05-01T12:08:49.196704+00:00 app[web.1]: ^
2018-05-01T12:08:49.196706+00:00 app[web.1]:
2018-05-01T12:08:49.196709+00:00 app[web.1]: Error: spawn babel-node ENOENT
2018-05-01T12:08:49.196710+00:00 app[web.1]: at _errnoException (util.js:1024:11)
2018-05-01T12:08:49.196712+00:00 app[web.1]: at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
2018-05-01T12:08:49.196714+00:00 app[web.1]: at onErrorNT (internal/child_process.js:372:16)
2018-05-01T12:08:49.196717+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:138:11)
2018-05-01T12:08:49.196718+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:180:9)
2018-05-01T12:08:49.196720+00:00 app[web.1]: at Function.Module.runMain (module.js:678:11)
2018-05-01T12:08:49.196721+00:00 app[web.1]: at startup (bootstrap_node.js:187:16)
2018-05-01T12:08:49.196723+00:00 app[web.1]: at bootstrap_node.js:608:3
2018-05-01T12:08:49.206967+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-05-01T12:08:49.208660+00:00 app[web.1]: npm ERR! errno 1
2018-05-01T12:08:49.211774+00:00 app[web.1]: npm ERR! rearn#1.0.0 start: `cross-env NODE_ENV=production babel-node server/server.js`
2018-05-01T12:08:49.212391+00:00 app[web.1]: npm ERR! Exit status 1
2018-05-01T12:08:49.212731+00:00 app[web.1]: npm ERR!
2018-05-01T12:08:49.212944+00:00 app[web.1]: npm ERR! Failed at the rearn#1.0.0 start script.
2018-05-01T12:08:49.213151+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-05-01T12:08:49.220087+00:00 app[web.1]:
2018-05-01T12:08:49.220400+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-05-01T12:08:49.220579+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-05-01T12_08_49_214Z-debug.log
2018-05-01T12:08:49.315806+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-01T12:08:49.301459+00:00 heroku[web.1]: Process exited with status 1
package.json:
{
"name": "rearn",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "8.9.3",
"npm": "5.6.0"
},
"scripts": {
"build": "next build",
"start": "cross-env NODE_ENV=production babel-node server/server.js",
"test": "eslint pages components lib",
"dev": "nodemon server/server.js --watch server --exec babel-node server/server.js",
"port": "cross-env PORT=4000 npm start",
"prod": "yarn build && cross-env NODE_ENV=production babel-node server/server.js",
"precommit": "yarn test",
"prepush": "yarn test",
"heroku-postbuild": "YARN_PRODUCTION=false yarn install && yarn build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#zeit/next-sass": "^0.1.2",
"axios": "^0.18.0",
"bootstrap": "4.0.0",
"bootstrap-material-design": "^4.1.1",
"connect-mongo": "^2.0.1",
"cross-env": "^5.1.4",
"dotenv": "^5.0.1",
"express": "^4.16.3",
"express-session": "^1.15.6",
"express-useragent": "^1.0.12",
"jquery": "^3.3.1",
"material-ui": "^0.20.0",
"mongoose": "^5.0.15",
"next": "5.1.0",
"next-offline": "^2.5.0",
"next-redux-wrapper": "^1.3.5",
"node-sass": "^4.8.3",
"passport": "^0.4.0",
"passport-google-oauth": "^1.0.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-popper": "^0.10.1",
"react-redux": "^5.0.7",
"react-reveal": "^1.2.1",
"react-transition-group": "^2.3.0",
"redux": "^4.0.0",
"redux-form": "^7.3.0",
"redux-thunk": "^2.2.0",
"styled-jsx": "^2.2.6",
"workbox-background-sync": "^3.0.1"
},
"browserslist": [
"> 1%"
],
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"eslint": "4.9.0",
"eslint-config-airbnb": "16.1.0",
"eslint-plugin-compat": "^2.2.0",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-jsx-a11y": "6.0.2",
"eslint-plugin-react": "7.4.0",
"husky": "^0.14.3"
}
}
Solved. Actually I was removing and installing babel-cli and babel-preset-env in bash and somehow heroku didn't update package.json remotely? Why? Solution:
installing babel-cli and babel-preset-env as dependencies instead of
devDependencies (actually babel-cli only is enough for next.js, as it uses latest babel config).
Found this post, since i had a similar problem.
moved the whole block of
"#babel/cli": "7.5.5",
"#babel/core": "7.5.5",
"#babel/node": "7.5.5",
"#babel/plugin-transform-runtime": "7.5.5",
"#babel/preset-env": "7.5.5",
"#babel/runtime": "7.5.5",
from devDepenencies to the dependencies section of package.json = problem solved for now, maybe not the final perfect solution, tough

Error: Cannot find module './Mime'

I am trying to get a heroku project running (following the tutorial here) and I'm running into a bit of trouble.
The node task on Heroku is throwing the following:
app[web.1]: module.js:540
app[web.1]: throw err;
app[web.1]: ^
app[web.1]:
app[web.1]: Error: Cannot find module './Mime'
app[web.1]: at Function.Module._resolveFilename (module.js:538:15)
app[web.1]: at Function.Module._load (module.js:468:25)
app[web.1]: at Module.require (module.js:587:17)
app[web.1]: at Object.<anonymous> (/app/node_modules/mime/index.js:3:12)
app[web.1]: at require (internal/module.js:11:18)
app[web.1]: at Module._compile (module.js:643:30)
app[web.1]: at Object.Module._extensions..js (module.js:654:10)
app[web.1]: at Module.load (module.js:556:32)
app[web.1]: at tryModuleLoad (module.js:499:12)
app[web.1]: at Function.Module._load (module.js:491:3)
I have installed (with -save) all of the dependencies I need including mime, but it seems like it's getting caught up with the mime module itself, here's the mime node_module:
1,545 .eslintrc.json
<DIR> .github
9,230 CHANGELOG.md
157 cli.js
127 index.js
1,098 LICENSE
101 lite.js
1,951 Mime.js
2,824 package.json
5,468 README.md
<DIR> src
<DIR> types
The mime/index.js file:
'use strict';
var Mime = require('./Mime');
module.exports = new Mime(require('./types/standard'), require('./types/other'));
and my project's dependencies
"dependencies": {
"body-parser": "^1.15.2",
"cheerio": "^1.0.0-rc.2",
"cookie-parser": "^1.4.3",
"express": "^4.14.0",
"express-handlebars": "^3.0.0",
"express-less": "^0.1.0",
"express-minify": "^0.2.0",
"favicon": "0.0.2",
"helmet": "^2.3.0",
"http": "0.0.0",
"logger": "0.0.1",
"mime": "^2.0.3",
"mongodb": "^2.2.11",
"morgan": "^1.7.0",
"nodemailer": "^4.4.1",
"nodemailer-sendgrid-transport": "^0.2.0",
"path": "^0.12.7",
"serve-favicon": "^2.3.0"
}
Thanks for your help!
Whelp, hard to say 100% what I did to fix the issue but it was probably one of the following things.
I added "engines": {"node": "7.5.0","npm": "4.1.2"} to my node package (see here)
I added a Procfile to the root with web: node server.js (see here)
as a side note, caching was a big issue for me after I solved this issue. This link may help with that.

Heroku app crashes after MongoDB updated to 3.0

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 <anom#gmail.com",
"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.
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 mongoose#4.1.9
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

Resources