Ineffective mark-compacts near heap limit Allocation failed - Nodejs app's tsc command while git push to dokku

Viewed 229

Issue

I ran into a JavaScript heap out of memory when trying to git push to a remote server (dokku). It occurred during the tsc command. However, I could run tsc perfectly fine in my local machine.

Things I tried

  1. I have tried increasing the heap memory in package.json by adding "start": "node --max-old-space-size=8192 dist/index.js", but still got the same error.
  2. Some said the node version might be less than 10 but mine is 16 so it should not be the case.

Error message

Step 8/15 : RUN yarn build
 ---> Running in f9d0db4c089e
yarn run v1.22.15
$ tsc

<--- Last few GCs --->
io[29:0x485a8a0]    28258 ms: Mark-sweep (reduce) 490.0 (492.6) -> 489.3 (494.1) MB, 737.1 / 4.0 ms  (+ 0.0 ms in 17 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 940 ms) (average mu = 0.268, current mu = 0.215) allocati[29:0x485a8a0]    29337 ms: Mark-sweep (reduce) 490.4 (493.1) -> 490.1 (494.6) MB, 681.4 / 0.0 ms  (+ 72.0 ms in 16 steps since start of marking, biggest step 20.2 ms, walltime since start of marking 1078 ms) (average mu = 0.287, current mu = 0.305) alloc

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xa389b0 node::Abort() [/usr/local/bin/node]
 2: 0x96e0af node::FatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0xbb7a4e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 4: 0xbb7dc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0xd73fd5  [/usr/local/bin/node]
 6: 0xd74b5f  [/usr/local/bin/node]
 7: 0xd8299b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
 8: 0xd8655c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 9: 0xd54c3b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
10: 0x109d21f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
11: 0x1446379  [/usr/local/bin/node]
Aborted (core dumped)
error Command failed with exit code 134.

In my package.json

"scripts": {
    "build": "tsc",
    "dev": "nodemon dist/index.js",
    "start": "node dist/index.js",
  },

My Dockerfile

FROM node:16

# Create app directory
WORKDIR /usr/src/app

COPY package.json ./
COPY yarn.lock ./

  
RUN yarn

COPY . .
COPY .env.production .env

RUN yarn build

ENV NODE_ENV production

EXPOSE 8080
CMD [ "node", "dist/index.js" ]
USER node  

Command I ran before getting the error is

git push dokku master to push to remote dokku hosted by Digital Ocean

0 Answers
Related