Cloudflare Pages Deployment Issue

Hello, I am trying to deploy an application using next-on-pages. The error message I get is

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

However, my function scripts are all well under 1 MiB as you can see below. I do not know why this is happening.

Relevant logs:

12:28:49.382	┌─────────────────────────────────────────────────────────────────────┬──────┬────────────┐
12:28:49.382	│ Name                                                                │ Type │ Size       │
12:28:49.382	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.382	│ __next-on-pages-dist__/cache/adaptor.js                             │ esm  │ 2.03 KiB   │
12:28:49.383	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.383	│ __next-on-pages-dist__/cache/cache-api.js                           │ esm  │ 0.43 KiB   │
12:28:49.383	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.383	│ __next-on-pages-dist__/cache/kv.js                                  │ esm  │ 0.31 KiB   │
12:28:49.383	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.384	│ __next-on-pages-dist__/functions/api/case/[id].func.js              │ esm  │ 392.12 KiB │
12:28:49.384	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.384	│ __next-on-pages-dist__/functions/api/case/member.func.js            │ esm  │ 393.79 KiB │
12:28:49.384	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.385	│ __next-on-pages-dist__/functions/api/case/new.func.js               │ esm  │ 392.74 KiB │
12:28:49.385	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.385	│ __next-on-pages-dist__/functions/api/case.func.js                   │ esm  │ 392.13 KiB │
12:28:49.385	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.385	│ __next-on-pages-dist__/functions/api/organizations/join.func.js     │ esm  │ 392.68 KiB │
12:28:49.386	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.386	│ __next-on-pages-dist__/functions/api/organizations/new.func.js      │ esm  │ 375.17 KiB │
12:28:49.386	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.386	│ __next-on-pages-dist__/functions/api/protected/upload.func.js       │ esm  │ 463.32 KiB │
12:28:49.386	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.386	│ __next-on-pages-dist__/functions/api/user/domain.func.js            │ esm  │ 214.50 KiB │
12:28:49.386	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.386	│ __next-on-pages-dist__/functions/api/user/getAll.func.js            │ esm  │ 392.07 KiB │
12:28:49.386	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.387	│ __next-on-pages-dist__/functions/api/user/orgName.func.js           │ esm  │ 214.47 KiB │
12:28:49.387	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.387	│ __next-on-pages-dist__/functions/api/user/search.func.js            │ esm  │ 392.15 KiB │
12:28:49.387	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.387	│ __next-on-pages-dist__/functions/src/middleware.func.js             │ esm  │ 278.56 KiB │
12:28:49.387	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.387	│ __next-on-pages-dist__/manifest/27d10e462fba646daaa29468a0656e12.js │ esm  │ 1.11 KiB   │
12:28:49.388	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.388	│ __next-on-pages-dist__/webpack/1282.js                              │ esm  │ 5.04 KiB   │
12:28:49.388	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.388	│ __next-on-pages-dist__/webpack/3409.js                              │ esm  │ 0.09 KiB   │
12:28:49.388	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.388	│ __next-on-pages-dist__/webpack/465e80f4a104b9629d2a927cb032a10e.js  │ esm  │ 0.68 KiB   │
12:28:49.388	├─────────────────────────────────────────────────────────────────────┼──────┼────────────┤
12:28:49.388	│ __next-on-pages-dist__/webpack/8581.js                              │ esm  │ 0.29 KiB   │
12:28:49.389	└─────────────────────────────────────────────────────────────────────┴──────┴────────────┘
12:28:49.454	✨ Compiled Worker successfully
12:28:49.537	Found _routes.json in output directory. Uploading.
12:28:49.550	Validating asset output directory
12:28:50.254	Deploying your site to Cloudflare's global network...
12:28:53.267	Parsed 1 valid header rule.
12:28:54.517	Uploading... (68/97)
12:28:55.409	Uploading... (78/97)
12:28:55.625	Uploading... (88/97)
12:28:55.886	Uploading... (97/97)
12:28:55.886	✨ Success! Uploaded 29 files (68 already uploaded) (1.69 sec)
12:28:55.886	
12:28:56.156	✨ Upload complete!
12:28:58.625	Success: Assets published!
12:29:00.887	Error: Failed to publish your Function. Got error: Your Functions script is over the 1 MiB size limit (workers.api.error.script_too_large)

My team recently experienced something similar. It turns out the error message is misleading. The sum of the size of the functions should be under 1 MiB, not each function individually. We ended up switching to Vercel for that project. Hope this helps.

F