Heroku上的节点应用程序段错误:std :: bad_alloc并退出代码134

时间:2019-05-14 14:22:18

标签: node.js debugging heroku segmentation-fault

我很难理解此heroku堆栈跟踪。几年来,我的应用程序在本地和Heroku上都运行良好。然而,我突然被Heroku的坠机困扰。这是堆栈跟踪:

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.

其他说明:

  • Heroku内存使用情况在配额之内。
  • 在本地一切正常。
  • 我的heroku应用已链接到github存储库,我已将其恢复为崩溃前的提交,但无济于事。
  • node_modules/未跟踪。
  • 我已按照these的指示清除缓存。

这是我的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"
  }
}

有人可以帮助我了解如何尝试调试吗?

1 个答案:

答案 0 :(得分:1)

确保我的package.json使用与在本地运行的相同版本的node和npm,为我解决了这个难题。

  "engines": {
    "node": "12.1.0",
    "npm": "6.9.0"
  },