Next.js Discord

Discord Forum

Using App router is resulting in out of memory error.

Unanswered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
I have a Dockerized Nextjs 14.2 project which was working fine, until yesterday, when I pushed a significant piece of functionality built on top the App Router. The other parts of the app are still using the Pages router.

The project is open source and is located here: https://github.com/codelitdev/courselit

My docker-compose config

version: "3.7"

services:
  app:
    image: codelit/courselit-app:${TAG}
    environment:
      - NODE_ENV=production
      - DB_CONNECTION_STRING=${DB_CONNECTION_STRING}
    restart: on-failure
    networks:
      - cl-apps 
    deploy:
      replicas: 2
      resources:
        limits:
          memory: 700M


I have two replicas as there is a memory leak in the app (which I can't detect) and the containers end up taking entire RAM before getting killed.

Error log

courselit-app-1    | <--- Last few GCs --->
courselit-app-1    | 
courselit-app-1    | [1:0x763e8566a650]    88639 ms: Scavenge (reduce) 345.8 (356.1) -> 345.3 (356.4) MB, 2.02 / 0.01 ms  (average mu = 0.204, current mu = 0.034) allocation failure; 
courselit-app-1    | [1:0x763e8566a650]    89221 ms: Mark-Compact (reduce) 346.1 (356.4) -> 344.1 (356.4) MB, 574.87 / 0.03 ms  (average mu = 0.268, current mu = 0.375) allocation failure; scavenge might not succeed
courselit-app-1    | 
courselit-app-1    | 
courselit-app-1    | <--- JS stacktrace --->
courselit-app-1    | 
courselit-app-1    | FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
courselit-app-1    | ----- Native stack trace -----

0 Replies