Plavna needed a service that can screenshot author's custom article previews (to only load images and not the whole code of previews before user hovers). The Screenshotter had to work on Vercel, possibly be a separate service (to not eat the free compute limits of the main service if needed) and be capable of retries.
To overcome the absence of Queue primitives on Vercel I had to:
- Create ScreenshotsQueue table in main service DB
- Create the function that queries the queue table, launches (if there's a task) the headless browser (yes, on Vercel functions), makes a screenshot, uploads the screenshot with Plavna Image Uploader and reports to the main service.
- Call this function at least 260 000 times per month for free (so we have at least somewhat small delays between new task and a ready screenshot) – Plavna Cron allowed for that.
If you're interested in code succesfully doing all that, you can contact me on X/Twitter and I might open source it.