Worker exceeded resource limits

I deployed my site and it's working, but if I refresh it a few (~6) times in a row then I get an Error 1102 exceeded resource limits. What can I do to prevent this?
13 Replies
jjjrmy
jjjrmyOP11mo ago
{
"name": "Error",
"message": "Worker exceeded CPU time limit.",
"timestamp": 1704161595906
}
{
"name": "Error",
"message": "Worker exceeded CPU time limit.",
"timestamp": 1704161595906
}
Yatsuki
Yatsuki11mo ago
use the new pricing model
jjjrmy
jjjrmyOP11mo ago
@Yatsuki but shouldn't this not be a problem at all? Shouldn't the response be cached?
Yatsuki
Yatsuki11mo ago
well idk how workers caching works but id try to implement my own cache logic
DaniFoldi
DaniFoldi11mo ago
Workers sit in front of Cloudflare's cache, so using the cache API won't prevent the worker from being invoked.
jjjrmy
jjjrmyOP11mo ago
@PurpleBlob but what can I do about the CPU time? Like the site loads fine but if you refresh a few time it gets that error? Shouldn't each load time be independent? https://offer-template.pages.dev/
DaniFoldi
DaniFoldi11mo ago
Enforcing the limits is done quite leniently, so you can go over once in a while - I think it uses the mean to check if your worker should be terminated And if you reload the page a couple times, causing that mean to go up, you suddenly start getting 1102s
Chaika
Chaika11mo ago
plus you get some leniency on the first time your script is loaded on that machine, some ~400ms for worker startup time Under your Pages Project under Function Metrics you should be able to see your Median CPU Time I'm guessing it's super high and you have some issue with doing something really expensive each request, could be a dependency or something
jjjrmy
jjjrmyOP11mo ago
No description
jjjrmy
jjjrmyOP11mo ago
I guess the free tier is only 10ms? and I'm basically always over that
Chaika
Chaika11mo ago
yes also yes, which explains your issue You really shouldn't need 300ms to render or load a page, something is wrong. You're using Nuxt?
jjjrmy
jjjrmyOP11mo ago
yes Nuxt I'll see if any optimizations can be done probably something to do with loading / replacing for the translations
maiku4823
maiku482311mo ago
I ran into this problem today while I was doing a bunch of things on a heavier page. It first said I was over limits with a pretty HTML page, then all subsequent loads reported for all other pages (non- prerendered) as 'Not found' with a simple text response. Are there no alerts on this? Kind of disturbing that users get a simple Not found response rather than the over usage response (over usage appeared once and only once). How would I know what to troubleshoot if I wasn't the one to see that first over usage response? An email or something recommending an upsell or whatever would work. This was with a sveltekit pages app, so everything not prerendered failed.
Want results from more Discord servers?
Add your server