FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
Unanswered
Spectacled bear posted this in #help-forum
Spectacled bearOP
I'm trying to generate a ton of static pages using
How to avoid the heap error (see below)?
page.tsx:
actions.ts:
Running
generateStaticParams as follows.How to avoid the heap error (see below)?
page.tsx:
import { getAllCombis } from "@/app/actions";
export const dynamicParams = false
const combis = await getAllCombis()
export default async function HpDetail({ params }) {
return <>{params.hpId.split('-').join(' ')}</>
}
export const generateStaticParams = async ({ params }) => {
return combis.map((combi, idx) => ({ hpId: combi.combiSlug }))
};actions.ts:
'use server'
import combisDb from "@/lib/combis.json"
import { getSlug } from "@/utils"
export async function getAllCombis(){
const allCombisData = combisDb
return allCombisData.map((combi, i) => {
const combiString = combi.join(' ');
return {
combiArray: combi,
id: i,
combiString,
combiSlug: getSlug(combiString),
}
})
}Running
npm run build I get this error: ✓ Linting
Collecting page data .getAllCombis action
✓ Collecting page data
<--- Last few GCs --->
[16284:000001369BF60080] 201262 ms: Scavenge (reduce) 1853.9 (1901.8) -> 1853.8 (1886.8) MB, 93.03 / 0.00 ms (average mu = 0.972, current mu = 0.915) allocation failure;
[16284:000001369BF60080] 203334 ms: Mark-Compact (reduce) 2081.3 (2113.5) -> 2080.1 (2114.2) MB, 1333.12 / 0.00 ms (+ 54.6 ms in 237 steps since start of marking, biggest step 2.4 ms, walltime since start of marking 2370 ms) (average mu = 0.913, curren
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----
1: 00007FF77881663B node::SetCppgcReference+18123
...
18: 00007FFE8DFD257D BaseThreadInitThunk+29
19: 00007FFE8FD2AA48 RtlUserThreadStart+40
⨯ Static worker exited with code: 134 and signal: null
Generating static pages (0/1938057) [ ]