The Cloudflare Feature You're Not Using (But Should Be)
Originally aired on September 19 @ 6:30 AM - 7:00 AM EDT
English
Transcript (Beta)
There's a feature at Cloudflare that most people don't even know exists, and it completely changes how you build async workflows.
No queues, no cron jobs. I used it to build an expense tracker that uploads a receipt, runs OCR, and stores everything automatically.
Let me show you how it works, and why you should probably be using this already.
So let's start by showing you how most developers would build this.
You've got a worker. It receives an image upload. It calls an OCR API.
It parses the result. And it stores the data all in one request. And honestly, that works.
For a demo. Here's where it falls apart, though. A user uploads a massive receipt image.
The OCR call takes 8 seconds. Your worker just times out. Or the image upload works.
OCR parsing works. But the database write fails. Now you've got a parsed expense floating in memory and nothing in the database.
No recovery. Just gone.
The problem isn't your code. The problem is that you're trying to do four different things in one synchronous request.
And the moment any one of them fails, the whole thing falls over.
There's a much better way to handle this. And it's already built into Cloudflare.
Now here's where Cloudflare Workflows changes everything.
Instead of one worker doing all of the work, you define a workflow. A series of durable steps.
Each step runs independently. Each step can retry on its own.
And state passes between them automatically. Think of it like an assembly line.
If station 3 breaks, you don't restart the whole factory. You just fix station 3 and pick up where you left off.
So let me walk you through the build. Step 1.
A worker receives an image and uploads and stores it to R2. That's your object storage.
The image is safe. The worker's job is done. Step 2. The actual workflow kicks off.
It grabs that image from R2 and sends it off to worker AI for OCR.
This is where the text extraction happens. Step 3. We parse that OCR output into structured data.
Merchant name. Total amount. Date. The stuff you actually care about.
Step 4. Write that data to D1. Your database. The expense is stored, structured, and queryable.
Now here's the part that matters. Each of these steps is defined separately in your workflow.
You configure retry logic per step. The state from one step flows automatically into the next.
If step 2 fails, step 1 doesn't run again.
Your image is already in R2. Workflows just picks up exactly where it fell off.
But the real reason you want workflows isn't the happy path. It's what happens when things break.
And inevitably, they always do. So watch this. I'm going to force this OCR step to fail.
In a naive approach, this is a silent disaster. The request errors out.
The user gets a 500. The image is gone. Nothing was saved. Next step, the user re-uploads the image.
And praise. Not a great user experience. With workflows, it retries automatically.
The image is still in R2 from step 1. Workflows rerun step 2.
Just step 2. And the pipeline continues. The user doesn't even know anything went wrong.
That's the difference. It's not about writing less code.
It's about your app continuing to work even when real-world conditions affect it.
So if your backend has multiple steps where each one could fail independently, Flare Workflows handles the hard part for you.
Durable steps. Built-in retry.
State management between steps. You don't need to set up queues. Although queues are awesome.
And we have a really good video on queues that you should also check out.
You don't need custom cron jobs. And you don't need to build your own retry logic.
It's all done for you. And this pattern goes way beyond expense tracking.
Image moderation pipelines. Multi-step onboarding flows. Document processing.
Anywhere you've got a chain of work that needs to be reliable every step of the way.
Honestly, I wish I'd found this sooner. If you're building with Cloudflare and you haven't yet checked out workflows, this is your sign.
Links to the docs and the demo repo are in the description below.
Lastly, we just recently released a new email service.
And if you want to check that out, we've got a full video for you.
