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

23
May 15, 2019, at 8:40 PM

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?

Answer 1

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"
  },
READ ALSO
socket.io is not working with simple-peer

socket.io is not working with simple-peer

i am willing to build one-to-one video chatroom with Socketio & Simple-Peer and for one-to-one algorithm i used socket

23
ORM for oracle DB in nodejs

ORM for oracle DB in nodejs

could you please suggest me better ORM for Oracle DB ?

39
Get loopback models using loopback-datasource-juggler

Get loopback models using loopback-datasource-juggler

Is there any other way other than getting the loopback model by using app object in a custom js file?

15
How to test mongoose.connect callback method with Jest

How to test mongoose.connect callback method with Jest

I've started making a new Express application, and the testing framework of choice is Jest

43