Make Any TypeScript Function Durable
42 comments
·October 23, 2025Etheryte
MrJohz
Decorators don't work for functions, unfortunately, so wouldn't work in this case. You'd need to add a bunch of class boilerplate to make it work.
JavaScript didn't have a lot of great options for this kind of statically-declared metaprogramming, which is why the "use X"; syntax has become so popular in various spaces. It's definitely not my favourite approach, but I don't think there's any clear "best" solution here.
halflife
You can use generator fns to achieve the exact same thing without magic strings or bundles. And the bonus is that you can debug it.
tom1337
Yea but it's a vercel product and they also pushed the 'use server' and 'use client' directives and probably want to build on them.
javcasas
My bad, this is open telemetry stuff to check the status of your servers, not for vendors to extract as much data as they can from you.
> I'm trying to find how they implemented the "use workflow" thing, and before I could find it I already found https://github.com/vercel/workflow/blob/main/packages/core/s...
> Telemetry is part of the core.
> Yuck.
nakovet
It's on the landing page, there is not even a standalone mode yet, so you can't use it with node.js you need to use with Next.js. All to say, it's just early alpha preview, I would wait the project to mature before considering using it anywhere.
javcasas
My bad, this is open telemetry stuff to check the status of your servers, not for the vendor to slurp as much data from you as possible.
oompydoompy74
It’s apparently an swc compiler plugin.
ajkjk
or no-op functions like useWorkflow() (with some kind of stub that prevents dead code elimination).
halflife
So vercel is adamant on making nextjs apps behavior completely unpredictable and hidden behind tons of magic code?
At least in any other framework library I can just command click and see why things are not working, place breakpoints and even modify code.
lopatin
It’s a great business model with epic lock in. Bored front end devs keep indulging / enabling it so why stop?
trevor-e
So this seems similar to https://temporal.io/, am I reading this right? I used that briefly a few years ago and it was pretty nice at the time. It did make some features much easier to model like their welcome email example. Would love to hear from someone with extensive temporal experience, iirc the only drawback was on the infra side of things.
AgentME
This seems pretty similar to Cloudflare Workflows (https://developers.cloudflare.com/workflows/), but with code-rewriting to use syntax magic (functions annotated with "use workflow" and "use step") instead of Cloudflare's `step.do` and `step.sleep` function calls. (I think I lightly prefer Cloudflare's model for not relying on a code-rewriting step, partly because I think it's easier for programmers to see what's going on in the system.) Workflow's Hooks are similar to Cloudflare's `step.waitForEvent` + `instance.sendEvent`. It's kind of exciting to see this programming model get more popular. I wonder if the ecosystem can evolve into a standardized model.
tom1337
So at it's core this is "just" a toolkit to add automatic retries to functions inside another function? I don't know if the audience Vercel is targetig knows about idempotency as well as they should before plastering all their functions with "use workflow".
I guess in the end it's another abstraction layer for queues or state machines and another way to lock you into Vercel.
zzixp
This is actually pretty cool. We have a similar custom library at Xbox that's used extensively across all of our services.
I do wish that there was some kind of self-hostable World implementation at launch. If other PAAS providers jump onto this, I could see this sticking around.
lloydatkinson
Azures Durable Task Framework or something else? I guess there’s nothing public on it, which is a shame because it sounds interesting
TimTheTinker
I'd rather be explicit about what's going on at each step. That way idempotent functions can be handled differently, retry limits can be applied, and no separate preprocessor is required.
export async function welcome(userId: string) {
const user = await retry(() => getUser(userId));
const { subject, body } = await retry(() => generateEmail({
name: user.name, plan: user.plan
}));
const { status } = await retry(() => sendEmail({
to: user.email,
subject,
body,
}), 2);
return { status, subject, body };
}
lloydjones
"use turnMyBrainOff";
"use blackBoxWrapperForEverything";
pavel_lishin
Am I stupid, or does the page not actually explain that workflow is?
davey48016
It doesn't explain it on the landing page. Even skimming their docs, it seems like you mostly have to infer the purpose of this based on the features.
drawfloat
Use client and use server aren’t great, but the fact they had to be declared at the top of a file was at least clear.
Starting to scatter magic strings throughout a code base feels like a real step back.
c-hendricks
There's nothing about "use server" that requires it to be at the top of the file though, it can go in function bodies and you have a typed RPC method.
I think "use client" is the only one that has to go at the top of a file.
TimReynolds
You are correct. Use server can be slapped in many places
0xb0565e486
Somewhat related since this about "workflows" and not cloud function, but are there any practical benefits to cloud functions other than the fact that it's cheaper for the providers as they don't have to run an entire bespoke runtime for every customer/application?
LewisJEllis
can anyone point to the "Durable" part?
looking at the docs and examples, I see Workflows and Steps and Retries, but I don't see any Durable yet. none of the examples really make it clear how or where anything gets stored
Of all the syntax options they could've gone with, they settled on what I would say is arguably the worst. If you want a one-liner, decorators are widely used across different languages and Typescript supports them as well.