-
Notifications
You must be signed in to change notification settings - Fork 10.4k
workflows: new docs #21313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
workflows: new docs #21313
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0331484
workflows: new docs
elithrar f3d08fb
update
elithrar 5286ca7
remove beta badge
elithrar dd0c5c3
limits
elithrar 81fa8f4
pricin
elithrar b0b0e87
waitForEvent more
elithrar 097e4ca
hidden: true
elithrar cf2a3c8
flesh out examples
elithrar eb20532
changelog done
elithrar 0132f8c
final
elithrar 60125b2
Apply suggestions from code review
elithrar ac5ab12
ok
elithrar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/content/changelog/workflows/2025-04-07-workflows-ga.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| --- | ||
| title: Workflows is now Generally Available | ||
| description: Workflows is now GA - ship Workflows that you can rely on in production. | ||
| - workflows | ||
| - workers | ||
| date: 2025-04-07T13:00:00Z | ||
| hidden: true | ||
| --- | ||
|
|
||
| import { Render, PackageManagers, TypeScriptExample } from "~/components" | ||
|
|
||
| [Workflows](/workflows/) is now _Generally Available_ (or "GA"): in short, it's ready for production workloads. Alongside marking Workflows as GA, we've introduced a number of changes during the beta period, including: | ||
|
|
||
| * A new `waitForEvent` API that allows a Workflow to wait for an event to occur before continuing execution. | ||
| * Increased concurrency: you can [run up to 4,500 Workflow instances](/changelog/2025-02-25-workflows-concurrency-increased/) concurrently — and this will continue to grow. | ||
| * Improved observability, including new CPU time metrics that allow you to better understand which Workflow instances are consuming the most resources and/or contributing to your bill. | ||
| * Support for `vitest` for testing Workflows locally and in CI/CD pipelines. | ||
|
|
||
| Workflows also supports the new [increased CPU limits](/changelog/2025-03-25-higher-cpu-limits/) that apply to Workers, allowing you to run more CPU-intensive tasks (up to 5 minutes of CPU time per instance), not including the time spent waiting on network calls, AI models, or other I/O bound tasks. | ||
|
|
||
| #### Human-in-the-loop | ||
|
|
||
| The new `step.waitForEvent` API allows a Workflow instance to wait on events and data, enabling human-in-the-the-loop interactions, such as approving or rejecting a request, directly handling webhooks from other systems, or pushing event data to a Workflow while it's running. | ||
|
|
||
| Because Workflows are just code, you can conditionally execute code based on the result of a `waitForEvent` call, and/or call `waitForEvent` multiple times in a single Workflow based on what the Workflow needs. | ||
|
|
||
| For example, if you wanted to implement a human-in-the-loop approval process, you could use `waitForEvent` to wait for a user to approve or reject a request, and then conditionally execute code based on the result. | ||
|
|
||
| <TypeScriptExample> | ||
|
|
||
| ```ts | ||
| import { Workflow, WorkflowEvent } from "cloudflare:workflows"; | ||
|
|
||
| export class MyWorkflow extends WorkflowEntrypoint<Env, Params> { | ||
| async run(event: WorkflowEvent<Params>, step: WorkflowStep) { | ||
| // Other steps in your Workflow | ||
| let event = await step.waitForEvent<IncomingStripeWebhook>("receive invoice paid webhook from Stripe", { type: "stripe-webhook", timeout: "1 hour" }) | ||
| // Rest of your Workflow | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| </TypeScriptExample> | ||
|
|
||
| You can then send a Workflow an event from an external service via HTTP or from within a Worker using the [Workers API](/workflows/build/workers-api/) for Workflows: | ||
|
|
||
| <TypeScriptExample> | ||
|
|
||
| ```ts | ||
| export default { | ||
| async fetch(req: Request, env: Env) { | ||
| const instanceId = new URL(req.url).searchParams.get("instanceId") | ||
| const webhookPayload = await req.json<Payload>() | ||
|
|
||
| let instance = await env.MY_WORKFLOW.get(instanceId); | ||
| // Send our event, with `type` matching the event type defined in | ||
| // our step.waitForEvent call | ||
| await instance.sendEvent({type: "stripe-webhook", payload: webhookPayload}) | ||
|
|
||
| return Response.json({ | ||
| status: await instance.status(), | ||
| }); | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| </TypeScriptExample> | ||
|
|
||
| Read the [GA announcement blog](https://blog.cloudflare.com/workflows-is-now-generally-available/) to learn more about what landed as part of the Workflows GA. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.