Node app segfault on Heroku: std::bad_alloc and exit code 134 - node.js

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"
},

Related

heroku sh: 1: tsc: not found

this my scripts
{
"name": "fullstack-apollo-express-boilerplate-project",
"version": "1.0.0",
"description": "",
"main": "index.ts",
"scripts": {
"tsc": "./node_modules/typescript/bin/tsc",
"build": "rimraf ./build && tsc",
"dev": "nodemon",
"start": "npm run build && node build/index.js",
"codegen": "graphql-codegen --config ./codegen.yml",
"lint": "eslint . --ext .ts",
"lint-and-fix": "eslint . --ext .ts --fix",
"prettier-format": "prettier --config .prettierrc src/**/*.ts --write"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#graphql-codegen/cli": "^2.3.0",
"#graphql-codegen/typescript": "^2.4.1",
"#graphql-codegen/typescript-resolvers": "^2.4.2",
"#shopify/eslint-plugin": "^41.0.1",
"#types/bcryptjs": "^2.4.2",
"#types/cookie-parser": "^1.4.2",
"#types/mongoose-lean-virtuals": "^0.5.2",
"#types/nodemailer": "^6.4.4",
"#types/uuid": "^8.3.3",
"#typescript-eslint/eslint-plugin": "^5.5.0",
"#typescript-eslint/parser": "^5.5.0",
"eslint": "^8.4.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0",
"nodemon": "^2.0.15",
"prettier": "^2.5.1",
"ts-node": "^10.4.0",
"typescript": "^4.5.2"
},
"dependencies": {
"#types/express": "^4.17.13",
"#types/node": "^16.11.11",
"apollo-server-core": "^3.5.0",
"apollo-server-express": "^3.5.0",
"bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"crypto-random-string": "3.3.1",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-openid-connect": "^2.5.1",
"graphql": "^16.0.1",
"graphql-fields-list": "^2.2.4",
"graphql-parse-resolve-info": "^4.12.0",
"graphql-voyager": "^1.0.0-rc.31",
"i": "^0.3.7",
"jsonwebtoken": "^8.5.1",
"moment": "^2.29.1",
"mongoose": "^6.0.14",
"mongoose-lean-virtuals": "^0.9.0",
"nodemailer": "^6.7.2",
"rimraf": "^3.0.2"
}
}
when i do deploy i get error
2022-01-14T08:20:20.950719+00:00 app[web.1]: sh: 1: tsc: not found
2022-01-14T08:20:20.956238+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-01-14T08:20:20.956684+00:00 app[web.1]: npm ERR! syscall spawn
2022-01-14T08:20:20.956866+00:00 app[web.1]: npm ERR! file sh
2022-01-14T08:20:20.956950+00:00 app[web.1]: npm ERR! errno ENOENT
2022-01-14T08:20:20.961092+00:00 app[web.1]: npm ERR! fullstack-apollo-express-boilerplate-project#1.0.0 build: `rimraf ./build && tsc`
2022-01-14T08:20:20.961191+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-14T08:20:20.961291+00:00 app[web.1]: npm ERR!
2022-01-14T08:20:20.961337+00:00 app[web.1]: npm ERR! Failed at the fullstack-apollo-express-boilerplate-project#1.0.0 build script.
2022-01-14T08:20:20.961377+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-01-14T08:20:20.961191+00:00 app[web.1]: npm ERR! spawn ENOENT
2022-01-14T08:20:20.961291+00:00 app[web.1]: npm ERR!
2022-01-14T08:20:20.961337+00:00 app[web.1]: npm ERR! Failed at the fullstack-apollo-express-boilerplate-project#1.0.0 build script.
2022-01-14T08:20:20.961377+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I can't figure out what's the reason Everything works fine for me.
If you don't have a Procfile, Heroku will run your start script as a web process.
Your start script runs your build script, and your build script compiles your app using tsc:
"build": "rimraf ./build && tsc",
"start": "npm run build && node build/index.js",
// ^^^^^^^^^^^^^
This causes Heroku to try to compile your app every time your dyno starts, and since typescript is (correctly) a devDependency, tsc isn't available at runtime.
It doesn't make much sense to have your start script call your build script: your app only needs to be compiled once.
Modify your start script so it doesn't call your build script:
"build": "rimraf ./build && tsc",
"start": "node build/index.js",
Heroku automatically runs your build script at deploy time, and now it won't try to re-compile it at runtime.

How to get nodemon to kill process when a program crashes?

Perhaps I'm missing something, since I've never encountered this before, but I'm trying to run a Node/Express/Babel setup with nodemon, and every time there is a crash (almost), nodemon leaves the port in use, so I have to manually kill the process. I'm using Node 11.15.0 and MacOS 10.13.6 and the error I get is
events.js:170
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::4321
at Server.setupListenHandle [as _listen2] (net.js:1259:14)
at listenInCluster (net.js:1307:12)
at Server.listen (net.js:1395:7)
at listen (/Users/robertanthony/Documents/Projects/sandbox/axa/src/index.js:27:10)
at $initialConnection.$initialConnection.then (/Users/thisuser/Documents/Projects/sandbox/axa/node_modules/mongoose/lib/connection.js:723:13)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
Emitted 'error' event at:
at emitErrorNT (net.js:1286:8)
at processTicksAndRejections (internal/process/task_queues.js:81:17)
[nodemon] app crashed - waiting for file changes before starting...
My package.json is
{
"scripts": {
"start": "nodemon --exec babel-node src/index.js",
"lint": "eslint \"src/**/*.{js}\" --quiet",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "^8.1.0",
"express": "^4.17.1",
"express-async-handler": "^1.1.4",
"express-jwt": "^5.3.1",
"express-jwt-permissions": "^1.3.1",
"express-session": "^1.16.2",
"jsonwebtoken": "^8.5.1",
"mongodb": "^3.3.2",
"mongoose": "^5.7.1",
"winston": "^3.2.1"
},
"devDependencies": {
"#babel/core": "^7.6.0",
"#babel/node": "^7.6.1",
"#babel/preset-env": "^7.5.5",
"eslint": "^6.2.2",
"eslint-config-prettier": "^6.1.0",
"nodemon": "^1.19.2",
"prettier": "^1.18.2"
}
}
Perhaps it's something I'm doing wrong? Any help much appreciated -- If it's not obvious what the solution is, is there any way to run babel without nodemon? I tried 'node --exec' but that didn't work…

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

Mongolab and Mongoose Not connecting [duplicate]

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

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