1chbinamin
1chbinamin
CDCloudflare Developers
Created by 1chbinamin on 7/11/2024 in #workers-help
Is Workers viable for running a function that takes minutes to complete?
I have a JavaScript function with Promise calls. It is responsible for running a Lighthouse-comparable feature called PageSpeed Insights API. It takes minutes before the function is executed because, just like a normal Lighthouse feature in the browser, it calculates metrics like performance and SEO for every website URL in the array I provide to the function. The problem is that it runs in the foreground of my Next.js app, preventing my users from clicking on any link, which would abort the whole process. The solution would be to ensure it runs in the background while users can still use my app. When the function is finished, a certain action should be performed on the Supabase database, and my Next.js app should know one way or another (perhaps using a webhook) that the function is finished. I am wondering if Workers might be a good fit to take that function? I remember that it is based on Edge so perhaps it might be troublesome for a worker to execute a function that takes couple of seconds to complete? I've tried to check the docs about Workers but I did not understand much.
9 replies
CDCloudflare Developers
Created by 1chbinamin on 6/30/2024 in #pages-help
How to set a max limit on requests & CPU time to prevent pay-as-you-go charges and unexpected bills?
No description
4 replies