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...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help