Segmentation fault (core dumped) in a running node process running in docker container

Viewed 1865

My docker image is running on AWS ECS. It runs for some time and then the container crashes with the following message :

Segmentation fault (core dumped)
npm ERR! code ELIFECYCLE
npm ERR! errno 139
npm ERR! fantasyservice@1.0.0 server: tsc -p . && node --max-old-space-size=1700 ./dist/server.js
npm ERR! Exit status 139
npm ERR!
npm ERR! Failed at the fantasyservice@1.0.0 server script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-07-08T07_51_00_148Z-debug.log

I found that this issue occurs when one of the libraries using C++ modules fails. My package.json has the following dependencies installed -

"dependencies": {
    "@nestjs/graphql": "^6.5.3",
    "@types/bull": "^3.10.6",
    "@types/bull-arena": "^2.6.0",
    "@types/check-types": "^7.3.1",
    "@types/compression": "^1.0.1",
    "@types/cors": "^2.8.6",
    "@types/express": "^4.17.2",
    "@types/graphql-type-json": "^0.3.2",
    "@types/http-errors": "^1.6.2",
    "@types/jsonwebtoken": "^8.3.5",
    "@types/node": "^12.12.11",
    "@types/node-fetch": "^2.5.3",
    "@types/request": "^2.48.3",
    "@types/request-promise": "^4.1.45",
    "apollo-server-express": "^2.9.12",
    "bcrypt": "^3.0.7",
    "bull": "^3.12.1",
    "bull-arena": "^2.6.4",
    "check-types": "^11.0.0",
    "compression": "^1.7.4",
    "cookie-parser": "^1.4.4",
    "core-util-is": "^1.0.2",
    "cors": "^2.8.5",
    "easygraphql-format-error": "0.0.3",
    "express": "^4.17.1",
    "express-graphql": "^0.9.0",
    "express-winston": "^4.0.1",
    "graphql": "^14.5.8",
    "graphql-tools": "^4.0.6",
    "graphql-type-json": "^0.3.1",
    "http-errors": "^1.7.3",
    "is-my-json-valid": "^2.20.0",
    "jsonwebtoken": "^8.5.1",
    "newrelic": "^6.3.0",
    "object-mapper": "^6.0.1",
    "pg": "^7.13.0",
    "pug": "^2.0.4",
    "redis": "^2.8.0",
    "reflect-metadata": "^0.1.13",
    "request": "^2.88.0",
    "request-promise": "^4.2.5",
    "segfault-handler": "^1.3.0",
    "tsc-watch": "^4.0.0",
    "tsconfig-paths": "^3.9.0",
    "type-graphql": "^0.17.5",
    "typeorm": "^0.2.20",
    "typeorm-encrypted-column": "0.0.4",
    "typeorm-naming-strategies": "^1.1.0",
    "typescript": "^3.7.2",
    "webpack-dev-server": "^3.9.0",
    "winston": "^3.2.1",
    "winston-daily-rotate-file": "^4.2.1",
    "winston-loggly-bulk": "^3.0.1"
  }

And my docker file is the following

FROM node:10

RUN apt update

RUN npm install typescript -g

COPY package*.json ./

RUN npm install
RUN npm rebuild bcrypt --build-from-source

ADD . /app
WORKDIR /app

CMD npm run server

I have tried increasing the ulimit, changed the node version in docker file and reduced the --max-old-space-size but to no effect. I also found out that npm rebuild bcrypt --build-from-source fixes an issue with bcrypt that causes this problem and have added that in my docker file link.

0 Answers
Related