I am running a reactJs application in Production mode inside a Kubernetes pod.container runtime is docker. Pod status is Running but still we don't get UI. Also when I check logs I see the below JS stacktrace error. To run React application I have given below command
"build": "set max_old_space_size=8192 && webpack --mode production --max_old_space_size=8192 && serve -s dist -l 3000"
The error I see inside pod logs is
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
<--- Last few GCs --->
[114:0x5632d5a724a0] 27622 ms: Scavenge (reduce) 597.8 (600.3) -> 597.3 (600.3) MB, 3.2 / 0.0 ms (average mu = 0.185, current mu = 0.145) allocation failure
[114:0x5632d5a724a0] 27627 ms: Scavenge (reduce) 598.1 (600.3) -> 597.5 (600.6) MB, 2.4 / 0.0 ms (average mu = 0.185, current mu = 0.145) allocation failure
The problem is that --max_old_space_size
is MB and according to your question you are passing 8192 but your pod is limited in resources to 1024.
You need to do one of the following:
1. Change your pod spec to reserve an amount more than 8192.
2. Change your command to set --max_old_space_size
to a value under 1024.
3. Or change both, but you need to make sure your pod has enough memory
What happens if you just remove both of the max_old_space_size
altogether? Do you really need to override this?