-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to publish your Function. Got error: Error: Script startup exceeded CPU time limit. #54
Comments
I'm having the same issue right now, i'm not able to update my application because of that. In my case, the According with : https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time
In my tests, the For me, this is a deal breaker. I came to the conclusion that cloudflare pages and next.js only works for tiny projects at this moment. Right now, I'm working to get my project out of the cloudflare and considering Vercel, netlify or open-next for deploy to AWS. If you want a fast solution, probably cloudflare wouldn't fit :/ |
Sharing this experience with a very small project, 5 pages, not many additional dependencies and 2 pages using little data from getServerSideProps. |
I just created a layout component (just some html no server side things) and then created dummy pages with the calling layout. After duplicating the pages this problem appeared. Can publish with removing some of the dummies. //edit: build log
|
This Worker startup time limit is unfortunately unrelated to this project, and is just a fundamental limit of the Workers platform: https://developers.cloudflare.com/workers/platform/limits/#worker-startup-time If you can, try to move any work you do into request handlers rather than having it in global scope, as this moves the work from startup time to request time which may help here. |
Why isn't the CPU limit following the bundled/unbounded rules? |
Can you give us a specific example? I understand why this is closed, but it has become an immediate problem faced by sites using cloudflare pages and Nextjs and is an issue that should be addressed quickly to resolve. Cloudflare team should provide some kind of concrete solution. |
@nitaking Yeah this is a real issue and something that I believe very often developers can't do much about (especially if they include third party code which can do things at startup anyways). We've actually already got a solution for this and we should release it soon, but before we can do that some changes need to be made in wrangler and I believe Greg is looking into that. The solution will be next-on-pages splitting the code appropriately and lazy loading route code so that it is run only when needed resulting in a much lighter startup processing, so from a developer point of view you will hopefully only have to upgrade the next-on-pages package and things should just work 🙂👍 |
I am experiencing the same problem. Is there a workaround? |
Since this problem is present in other metaframeworks as well (e.g.: nuxt3 with nitro), would you mind sharing your findings so that it's possible to pass on these improvements in these other metaframeworks as well? |
Blocked me from using Pages today as well. Off to Vercel... |
@Rigo-m thanks a lot for the interest! 😃 and sorry for the late reply 😓 anyways I'll share the strategy in details when we add it to the project We're also planning to contact and try to work with metaframework authors to help in this, although we've seen that many metaframeworks will need to change how they bundle the _worker before they can apply such type of strategy (it also depends on how the metaframework itself works and how it splits its code). Anyways the strategy is simple, basically wrangler is introducing the ability to use dynamic imports, once we have those, instead of bundling everything together (which causes extra code to unnecessarily run) we add dynamic imports so that the code is evaluated and run only when actually used. In next-on-pages basically the idea is to have a basic worker which simply acts at the next server/router (with just the basic logic, so it's going to be much faster), then when it needs to use a route, only at that point it dynamically imports that route's code. ExampleSo for example let's say your app has now we kind of take all of that js code and bundle it together, so all the setup work for with dynamic imports, if you'll request I hope the above helps, as I said I'll probably make this much more clear and provide a more detailed description of this when we actually add it to the project 🙂 (which should hopefully be pretty soon) |
This is extremely encouraging. And extremely is an undestatement. Eagerly waiting to hear when this is finished, thanks a lot for your time! |
@Rigo-m Thanks for the ping. We are in contact now 😊 |
I got the same error. I only have one basic hello world /api function in a nextjs@13 project, that then fails to build on Cloudflare pages:
|
Similar experience |
#191 Since above two PR are still pending to merge, If you are in a hurry you can setup a GitHub action to manually deploy to CloudFlare pages. This is an example of Github Workflow file.
The trick here is to use the preview version of Follow this guide to set up your account id and api token: |
Awesome, thanks for the temporary fix suggestion @bruce-shi 😄 (Anyways hopefully the two PRs will get merged soon 🤞) |
Just merged the PR 🙂 @shiyuhang0, @mihazs, @saaymeen, @aufalmarom, @ynishimura, @uglyrobot, @lourou and @olajiredominic (and whoever I might have missed 😅) If you want please try out your apps with the latest beta release: https://www.npmjs.com/package/@cloudflare/next-on-pages/v/0.0.0-b33639f and let me how it goes, hopefully you should not hit the startup time limit anymore 🙂 |
after upgraded
And
BTW, version |
same error with version |
@zizifn yeah sorry, that's totally my bad, my change kind of broke this code: next-on-pages/src/buildApplication/buildWorkerFile.ts Lines 85 to 109 in 3e2dad8
(because now there is a bunch of code from Vercel that we don't process 😓) so sorry for the inconvenience, I'm on it 🙇 |
@zizifn should be all good now hopefully (sorry it took me a while I had to also deal with a runtime bug which I wasn't aware of 😓), please try again with the latest beta 🙂 🙏 (https://www.npmjs.com/package/@cloudflare/next-on-pages/v/0.0.0-4740c02) |
Different error now, and I have |
@dario-piotrowicz is there something I'm doing wrong or you can reproduce this new error in your side? |
@zizifn I'm so sorry I extensively looked into this and forgot to reply to you 😓 No, you're not doing things wrong, we've found out that there's actually currently a runtime bug which sort of causes the A colleague of mine has implemented a fix for it: cloudflare/workerd#634 but I am not sure when that will be available in the runtime (maybe this or next week) I kind of fixed this in my PR with a try-catch hack: https://github.com/cloudflare/next-on-pages/pull/232/files#r1190419297 It is not 100% not good, but as you can see from the apps I mentioned in the PR's description is sort of holding up decently (and anyways it'll be fixed as soon as the runtime's ready) So you can use my pre-release to build and deploy your application and hopefully now it should work nicely Unfortunately if you try to you won't be able to run the app locally because of a bug in PS: I'm so sorry for the inconvenience, one thing after another kept popping up here 😓 (but after I extensively tested my PR's apps I am confident that it's all almost sorted out 🙇) |
Hi, still having this issue. Is there any workaround for this? |
@lsgrep could you check if you are using the latest version of next-on-pages? is it possible that your index page is doing some (costly?) setup work? could you reduce that? in any case could you share your app so that we could have a look more in detail? |
Chiming in here - I'm using Remix rather than Next but have the same problems.
This is no doubt the issue, but when applications grow complex it's incredibly hard to pinpoint where that costly setup is coming from. It's only reproducible when pushing to Cloudflare, so the iteration cycle is slow and there seems to be no way to profile the generated script :( |
Having the same issue with a Remix + Hydrogen app, bundle size is 2.5MB |
According to this blog post - the startup time is increasing to 400ms from 200ms:
Not sure if that's live or not now. |
+1. |
me too - anyone know how to fix this? |
My bundle is 550kb and it still fails. Checked with https://github.com/btd/rollup-plugin-visualizer
I'm using Remix to server-render my app. It would be really useful to have some more information / tooling to see why that happens. Also it would be nice if the error states the absolute CPU time limit. |
I have the same error. Does anyone have a solution? |
@hawkcookie look at let { someFunction } = await import('./someModule') I'm using Remix, but if y'all are using another framework, the same principle could help you, just the entrypoints will be different. |
I am using nextjs and prisma data proxy to connect to a database.
Then I deploy to cloudflare pages but failed with
Script startup exceeded CPU time limit
.I don't know if it is the problem of my project or the work_js generated by next-on-pages.
The text was updated successfully, but these errors were encountered: