Skip to content

[Workflows] Implement Workflows instance methods#12814

Merged
pombosilva merged 3 commits intomainfrom
osilva/implement-workflows-instance-methods
Mar 12, 2026
Merged

[Workflows] Implement Workflows instance methods#12814
pombosilva merged 3 commits intomainfrom
osilva/implement-workflows-instance-methods

Conversation

@pombosilva
Copy link
Contributor

@pombosilva pombosilva commented Mar 9, 2026

Fixes WOR-1182.

This PR implements the 4 missing Workflow instance lifecycle methods for local dev: pause(), resume(), restart(), and terminate().

  • Pause: pause() sets WaitingForPause status, then it checks between steps, stores the pause timestamp, transitions to Paused, and aborts the DO. If there are any pending step.do's these will finish before going to Paused.
  • Resume: cancels a pending pause (WaitingForPause -> Running), or fully resumes after abort by offsetting priority queue timers by the pause duration and firing init().
  • Restart: aborts the DO, then on the fresh instance reads stored INSTANCE_METADATA, cleans up SQL/KV (preserving modifier keys and mocked event data), writes fresh logs, and fires init().
  • Terminate: sets status to Terminated and aborts.

Also:

  • Validated step configuration.
  • Aligned states table schema with production (DATETIME('now','subsec') for timestamp precision).
  • WorkflowHandle.status() auto-refreshes stale DO stubs after abort.

A picture of a cute animal (not mandatory, but encouraged)
image


Open with Devin

@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

🦋 Changeset detected

Latest commit: ec31b51

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pombosilva pombosilva force-pushed the osilva/implement-workflows-instance-methods branch from 9b5485f to 97ec0f8 Compare March 9, 2026 17:06
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Mar 9, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 9, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12814

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12814

miniflare

npm i https://pkg.pr.new/miniflare@12814

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12814

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12814

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12814

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12814

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12814

wrangler

npm i https://pkg.pr.new/wrangler@12814

commit: 24dac17

@pombosilva pombosilva force-pushed the osilva/implement-workflows-instance-methods branch 2 times, most recently from a959c17 to 32ee755 Compare March 10, 2026 14:42
@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

✅ All changesets look good

@pombosilva pombosilva force-pushed the osilva/implement-workflows-instance-methods branch from 32ee755 to c16a59a Compare March 10, 2026 14:44
@pombosilva pombosilva marked this pull request as ready for review March 10, 2026 14:52
@pombosilva pombosilva requested review from a team as code owners March 10, 2026 14:52
@workers-devprod
Copy link
Contributor

workers-devprod commented Mar 10, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/workflows
  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

@pombosilva pombosilva force-pushed the osilva/implement-workflows-instance-methods branch from c16a59a to fff99db Compare March 10, 2026 16:45
devin-ai-integration[bot]

This comment was marked as resolved.

@pombosilva pombosilva force-pushed the osilva/implement-workflows-instance-methods branch from fff99db to 56e0928 Compare March 10, 2026 16:57
Copy link
Contributor

@emily-shen emily-shen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm from the wrangler/miniflare side, can't say much about the actual workflows stuff 😅

while reviewing I noticed the readme for workflows-shared says this code is actually used by workflows infrastructure in prod, i assume that isn't actually true?

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Mar 11, 2026
@pombosilva pombosilva force-pushed the osilva/implement-workflows-instance-methods branch 2 times, most recently from b04fb74 to 01ff3de Compare March 11, 2026 12:30
devin-ai-integration[bot]

This comment was marked as resolved.

@pombosilva
Copy link
Contributor Author

while reviewing I noticed the readme for workflows-shared says this code is actually used by workflows infrastructure in prod, i assume that isn't actually true?

Yes that readme was wrong. Thanks for warning - I updated it

@pombosilva pombosilva force-pushed the osilva/implement-workflows-instance-methods branch 2 times, most recently from b680714 to a2b9408 Compare March 11, 2026 14:32
@pombosilva pombosilva force-pushed the osilva/implement-workflows-instance-methods branch from a2b9408 to 23165c3 Compare March 12, 2026 10:46
devin-ai-integration[bot]

This comment was marked as resolved.

@pombosilva pombosilva force-pushed the osilva/implement-workflows-instance-methods branch 2 times, most recently from 74a6fec to a8b5244 Compare March 12, 2026 11:44
@pombosilva pombosilva force-pushed the osilva/implement-workflows-instance-methods branch from a8b5244 to ec31b51 Compare March 12, 2026 11:58
@pombosilva pombosilva merged commit 8d4ef78 into main Mar 12, 2026
36 of 37 checks passed
@pombosilva pombosilva deleted the osilva/implement-workflows-instance-methods branch March 12, 2026 15:15
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Mar 12, 2026
edmundhung added a commit that referenced this pull request Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants