I'm relatively new to nextjs. I have a nextjs app deployed on Digital Ocean's App platform. In my latest build I added ISR due to a dynamic route having 100k+ endpoints that update once a week at most.
Now my DO server has the following memory and restart count:
[id].js:
export async function getStaticProps({ params }) {
const { id } = params;
const details = await getDetails(id);
return {
props: {
details
},
revalidate: 3600 * 6 // 6 hours in seconds
}
}
export async function getStaticPaths() {
const validPaths = [];
for(let i = 1; i <= 300; i++) {
const { name } = getDetails(i);
validPaths.push({ params : {id : name.toLowerCase() }});
}
return {
paths: validPaths,
fallback: 'blocking'
}
}
next.config.mjs:
const nextConfig = {
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
],
},
];
},
generateBuildId: () => buildId,
env: {
NEXT_PUBLIC_BUILD_ID_ENV: buildId,
NEXT_PUBLIC_DOMAINS: domains
},
swcMinify: false,
reactStrictMode: false,
assetPrefix: undefined,
images: {
domains: [domains],
unoptimized: true,
},
experimental: {
scrollRestoration: true,
esmExternals: true
},
webpack: (config, {isServer}) => {
return config;
},
}
Why is my server running out of memory and how can I work around it? Why isn't my server utilizing its full 2GB before restarting?