Paid plan : Failed to publish your Function. Got error: Your Functions script is over the 1 MiB size limit (workers.api.error.script_too_large)

How can this be solved ?
there are already many topics on the same issue and none of the issues has been answered.

I already have a site published on cloudflare pages and I added some extra code and the error propped up. So is this is a dead end ?
The limit of 1mb is absurdly low to create any good product over cloudflare pages. I purchased the pro plan as it seemed to mention that the limit would be 10mb but even in the paid plan the limit is 1mb.
I found another rant from a developer on this : Still stuck behind 1mb script size limit after upgrading to paid plan - Cloudflare Developers

1 Like

They were confused that you need Workers Paid (under the Workers & Pages Tab → Plans) to get the higher limit, not Cloudflare Pro or any Website plan. Is that what you’re confused about as well?

It’s your functions/worker size, not the total size of your Pages site. Pages assets themselves can be up to 25 MiB, and you can have up to 20,000 per deployment. The serverless code, in your function, is limited to 1 MB free / 10 MB Paid after compression. You still most of the time don’t want to go over the 1 MB threshold as your Worker gets higher startup times due/slower storage. The thing about Pages Assets is they only exist in two central stores (one in US/EU), but Workers/Functions exist everywhere waiting to be spun up, needing a lot more strict size limitations.

I would build the app locally and check the size of your _workers.js if you’re using a framework like next-on-pages which creates one. I would also look for dependencies which you are using which can be trimmed. 1 MB is pretty large for a Worker/Function, should be possible to trim some.

Its a nextJS SSR project, so we’re using edge compute but the problem is that I can not find a way how to determine this script size.

It is hard to understand how script size increases,
I’m facing an issue where the script size seems to increase unexpectedly. I have a simple setup with only two routes returning “Hello” and no additional content. However, upon deployment, I encounter a script_too_large error.

"use client";

//Some import statements

export const runtime = "experimental-edge";

export default function Page({ data }: MarketPlaceData) {
// print "Hello"

Is there an alternative approach to include more routes within the constraints of the free tier? Additionally, as my application grows, what options are available to seamlessly transition to a paid tier? Any insights or suggestions would be greatly appreciated!

which is the reference for this?

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.