Dream_hat
Dream_hat

Reputation: 43

Github - FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Getting this error in the GitHub job run and the run is stopping with error code 134.

Earlier it was working with size=4092.

We are running this on GitHub self-hosted runners with OS Linux

I have tried the memory size 8GB and 16GB with the below command but getting the same error.

Error in run- [3540:0x6918dd0] 4287822 ms: Scavenge 7973.4 (8149.9) -> 7972.9 (8162.2) MB, 18.0 / 0.0 ms (average mu = 0.140, current mu = 0.079) allocation failure

NODE_OPTIONS: "--max-old-space-size=8192"

NODE_OPTIONS: "--max-old-space-size=16384"

Is there any solution to this issue?

Upvotes: 0

Views: 492

Answers (1)

Piyush Bhangale
Piyush Bhangale

Reputation: 137

  1. If you have ngnix config file then check following things:
  • worker_connections: 16384 (for heavy frontend applications) [nginx default is 512 connections per worker, which is too low for modern applications]

  • use: epoll (efficient method) [nginx supports a variety of connection processing methods]

  • http: add following things to free your worker from getting busy in handling some unwanted task. (client_body_timeout , reset_timeout_connection , client_header_timeout,keepalive_timeout ,send_timeout).

  1. Remove all logging/tracking tools like APM , Kafka , UTM tracking, Prerender (SEO) etc middlewares or turn off.

3.Now code level debugging: In your main server file , remove unwanted console.log which is just printing a message.

  1. Now check for every server route i.e app.get() , app.post() ... below scenarios:
  • data => if(data) res.send(data) // do you really need to wait for data or that api returns something in response which i have to wait for?? , If not then modify like this:

    data => res.send(data) // this will not block your thread, apply everywhere where it's needed

  • else part: if there is no error coming then simply return res.send({}) , NO console.log here.

  • error part: some people define as error or err which creates confusion and mistakes. like this:

error => { next(err) } // here err is undefined

err => {next(error) } // here error is undefined

app.get(API , (re,res) =>{ error => next(error) // here next is not defined })

  • remove winston , elastic-epm-node other unused libraries using npx depcheck command.

  • In the axios service file , check the methods and logging properly or not like :

if(successCB) console.log("success") successCB(response.data) // here it's wrong statement, because on success you are just logging and then successCB sending outside the if block which return in failure case also.

  • Save yourself from using stringify , parse etc on accessive large dataset. (which i can see in your above shown logs too.
  1. Last but not least , for every time when your application crashes or pods restarted check the logs. In log specifically look for this section: Security context This will give you why , where and who is the culprit behind the crash.

Upvotes: 0

Related Questions