Next.js Discord

Discord Forum

Error on CF build

Answered
Western harvester ant posted this in #help-forum
Open in Discord
Western harvester antOP
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 Western harvester ant
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

Western harvester antOP
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.
Western harvester antOP
Okay.. it seems that it's a semi-common issue that's yet to be fixed?: https://github.com/vercel/next.js/discussions/50497
Western harvester antOP
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
@Western harvester ant 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
Western harvester antOP
I saw some people also post it using vercel.
A dev expert from CF also said this:
oh i see
@Western harvester ant 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.
Western harvester antOP
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