Triggering Long Jobs in Cloudflare Workers
dev.to·5d·
Discuss: DEV
☁️Cloudflare Workers
Preview
Report Post

I recently hit a wall with Cloudflare Workers that I’m sure many of you have encountered: how do you trigger a long-running background job on demand?

It seems simple enough—just call a function from your API, right? But Workers aren’t quite that straightforward, and I spent way too long trying to work around limitations that, it turns out, Cloudflare already solved for me.

Let me walk you through what I learned.


The Problem: My Job Was Too Long for HTTP

I had a Worker that handled my admin UI. One of the features was a button that kicked off a heavy background process—think scraping, data processing, batch operations, that kind of thing.

My first implementation was naive:

export default {
async fetch(request, env, ctx) {
if (request.url.endsWith('/admin/run-job')...

Similar Posts

Loading similar posts...