Skip to content

[workflows-shared] Cancel completed step timeout timers - #15939

Merged
dario-piotrowicz merged 6 commits into
cloudflare:mainfrom
00200200:fix/workflow-step-timeout-timer-quota
Oct 7, 2026
Merged

dario-piotrowicz merged 6 commits into
cloudflare:mainfrom
00200200:fix/workflow-step-timeout-timer-quota

Conversation

@00200200

@00200200 00200200 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #15788

Local Workflow step.do() starts a 10-minute scheduler.wait() for the step timeout. Completing the step aborted a JS controller and removed the priority-queue entry, but the native wait was started without { signal }, so workerd kept the timer until the original deadline. After 5,000 sequential immediate steps that hits the isolate's 10,000-timer quota (QuotaExceededError).

schedulerWait() now forwards the abort signal to scheduler.wait(), and the step timeout wait uses the combined step/engine abort signal. When the step finishes, workerd cancels the native timer.

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this is a local-runtime bug fix; production Cloudflare Workflows are unchanged, and there is no user-facing API or config change.

Note

This is a contribution from an AI agent: Cursor Grok 4.6.


Devin Review

Pass the step abort signal into scheduler.wait so workerd clears the
native timer when a step finishes, instead of accumulating until the
10-minute deadline and hitting the 10,000-timer quota.
@changeset-bot

changeset-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2bab1fe

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

This PR includes changesets to release 9 packages
Name Type
miniflare Patch
@cloudflare/workflows-shared Patch
@cloudflare/deploy-helpers Patch
@cloudflare/pages-shared Patch
@cloudflare/remote-bindings Patch
@cloudflare/runtime-types Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin Patch
wrangler Patch

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

@workers-devprod
workers-devprod requested review from a team and cjol and removed request for a team September 29, 2026 12:07
@workers-devprod

workers-devprod commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/workflows
  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/clear-timeout-quota.md: [@cloudflare/wrangler]
  • packages/workflows-shared/src/context.ts: [@cloudflare/workflows @cloudflare/wrangler]
  • packages/workflows-shared/src/lib/delay.ts: [@cloudflare/workflows @cloudflare/wrangler]
  • packages/workflows-shared/src/lib/gracePeriodSemaphore.ts: [@cloudflare/workflows @cloudflare/wrangler]
  • packages/workflows-shared/tests/engine.test.ts: [@cloudflare/workflows @cloudflare/wrangler]
  • packages/workflows-shared/tests/lib/delay.test.ts: [@cloudflare/workflows @cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15939

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15939

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@15939

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15939

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@15939

create-cloudflare

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

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15939

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15939

@cloudflare/pages-shared

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

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@15939

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@15939

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15939

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15939

wrangler

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

commit: 2bab1fe

Failed attempts only dropped the timeout PQ entry, so the native
scheduler.wait timer leaked until the original deadline. Abort the
attempt controller on the error path so long local workflows stay
under the isolate timer quota.
devin-ai-integration[bot]

This comment was marked as resolved.

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you very much for the fix @00200200 🙏

The change looks overall good to me (and I manually validated that this fixes the issue), but could you please address devin's comments? 🙏

@00200200

Copy link
Copy Markdown
Contributor Author

@dario-piotrowicz failed-step timers were already aborted in d08c975. I tightened the quota test so it no longer swallows unexpected errors (e.g. timer exhaustion).

devin-ai-integration[bot]

This comment was marked as resolved.

@00200200

Copy link
Copy Markdown
Contributor Author

@dario-piotrowicz Updated with the fix for paused recovered sleep entries in 2bab1fe. All vitest suites pass cleanly.

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks again @00200200 😄

Once @Caio-Nogueira approves we can merge this! 😄

@workers-devprod

workers-devprod commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

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

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@dario-piotrowicz
dario-piotrowicz merged commit e6f7663 into cloudflare:main Oct 7, 2026
65 checks passed
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Oct 11, 2026
…lpha (#879)

## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `miniflare` | 5.20261006.0-alpha | 5.20261006.1-alpha | prerelease |

## Release Notes

<details>
<summary><b>miniflare</b> (5.20261006.0-alpha →
5.20261006.1-alpha)</summary>

### Patch Changes

- [#16139](cloudflare/workers-sdk#16139)
[`2d1d563`](cloudflare/workers-sdk@2d1d563)
Thanks [@<!---->cpojer](https://github.com/cpojer)! - Update esbuild to
0.28.2

Align esbuild dependency with tooling using the latest 0.28 patch so
package managers can share one installation instead of downloading a
second native binary.

- [#15939](cloudflare/workers-sdk#15939)
[`e6f7663`](cloudflare/workers-sdk@e6f7663)
Thanks [@<!---->00200200](https://github.com/00200200)! - Fix local
Workflows hitting the timer quota on long runs

Long local workflows no longer fail from timer exhaustion. Step timeout
timers, sleep, waitForEvent, and grace-period waits now cancel their
underlying timers when finished or aborted, instead of remaining until
their original deadlines.

- [#16098](cloudflare/workers-sdk#16098)
[`fe607f9`](cloudflare/workers-sdk@fe607f9)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update dependencies of "miniflare", "wrangler"

  The following dependency versions have been updated:

  | Dependency | From   | To     |
  | ---------- | ------ | ------ |
  | sharp      | 0.35.4 | 0.35.5 |

- [#15879](cloudflare/workers-sdk#15879)
[`8de6b3c`](cloudflare/workers-sdk@8de6b3c)
Thanks [@<!---->dawNotPoi](https://github.com/dawNotPoi)! - Stop
Hyperdrive proxy listeners from accumulating across local development
reloads

Miniflare now reuses a listener when a Hyperdrive binding keeps the same
target and closes listeners no longer used after a configuration update.
Changing or removing a binding, including switching to
`sslmode=disable`, no longer leaves stale listening ports in `wrangler
dev`.

- [#16106](https://github.com/cloud

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/miniflare%405.20261006.1-alpha)

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

[Miniflare][Workflows] Completed steps leave timeout timers active, exhausting the 10,000-timer quota

4 participants