Next.js Discord

Discord Forum

Error on CF build

Answered
Sirex woodwasp posted this in #help-forum
Open in Discord
Sirex woodwaspOP
Anyone else getting "â–² Error: The initialStatus argument for Prerender must be a natural number."? It doesn't show any other errors and it's leaving me with nothing.
Answered by Sirex woodwasp
Seems that setting export const runtime = "edge"; fixes it, however the error should be a lot more precise to what it means and what file is incorrect.
View full answer

10 Replies

Sirex woodwaspOP
This is the build log, if it helps anyone: https://paste.techscode.com/erudoreyusaruwo.apache
One thing I noticed, is all my /api routes are 0 bytes, if that matters.
Sirex woodwaspOP
Okay.. it seems that it's a semi-common issue that's yet to be fixed?: https://github.com/vercel/next.js/discussions/50497
Sirex woodwaspOP
Seems that setting export const runtime = "edge"; fixes it, however the error should be a lot more precise to what it means and what file is incorrect.
Answer
@Sirex woodwasp Seems that setting `export const runtime = "edge";` fixes it, however the error should be a lot more precise to what it means and what file is incorrect.
i think this is specific to cloudflare; CF pages forces the edge runtime so you must add it everywhere
@joulev i think this is specific to cloudflare; CF pages forces the edge runtime so you must add it everywhere
Sirex woodwaspOP
I saw some people also post it using vercel.
A dev expert from CF also said this:
oh i see
@Sirex woodwasp Seems that setting `export const runtime = "edge";` fixes it, however the error should be a lot more precise to what it means and what file is incorrect.
Turkish Van
Hi fafa, where did you put this export const runtime = "edge" that made it work? I'm having same issue right now.
@Turkish Van Hi fafa, where did you put this export const runtime = "edge" that made it work? I'm having same issue right now.
Sirex woodwaspOP
This is pretty long ago! So I'm kind of unsure what happened here.

However, if you are using CF Pages, you need this on every page.jsx/page.tsx:
export const runtime = 'edge'; at the top