Skip to content

fix(miniflare): don't block the Node.js event loop in unsafeEvictDurableObject() - #17090

Merged
petebacondarwin merged 1 commit into
cloudflare:mainfrom
pelle:fix-evict-durable-object-blocks-node
Nov 23, 2026
Merged

petebacondarwin merged 1 commit into
cloudflare:mainfrom
pelle:fix-evict-durable-object-blocks-node

Conversation

@pelle

@pelle pelle commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #17089.

unsafeEvictDurableObject() (and execDurableObjectSql()) call the DevControl service through the proxy client. For non-Durable-Object targets that call is synchronous and blocks the Node.js main thread in Atomics.wait(). Eviction waits for the Durable Object's waitUntil() work, so if that work is waiting on Node.js (a function-valued service binding, node-handler, ...), neither side can proceed until workerd's 30s timeout.

Found with cloudflake (deterministic simulation testing for Workers): its Durable Object nemesis evicts objects at random points while a workload runs, with several Miniflare instances in one Node.js process. Seeds that evicted a Durable Object during background waitUntil() work reproduced the 30s timeout every time, plus collateral failures in sibling instances during the freeze.

Changes:

  • proxy/client.ts + core/constants.ts: isDevControlCall() forces dev control calls onto the async path, like Durable Object stubs.
  • core/proxy.worker.ts: an awaited RPC call that rejects now still gets the Promise result-type header. Before, only the success path set it, so an async call that threw (e.g. evicting a Durable Object that is not running) hit assert(typeHeader === "Promise") in the client instead of surfacing the real error.

Tests (test/index.spec.ts):

  • evicting a Durable Object with waitUntil() work that awaits a node-handler completes in ~0.4s with Node.js timers still ticking (fails with the 30s timeout without the fix)
  • evicting a Durable Object that is not running still rejects with "not currently running"

Verified locally: vitest run test/index.spec.ts test/plugins/core passes (202 passed, 1 skipped).


  • 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: internal bug fix, no API or option changes

Note

This PR was prepared with Claude Code (Claude Sonnet 5.5) on behalf of the submitter, who asked for it to be filed.


Devin Review

@changeset-bot

changeset-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 76dcfae

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/deploy-helpers Patch
@cloudflare/dev-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

@github-actions

Copy link
Copy Markdown
Contributor

Hi @pelle. Thanks for taking the time to contribute to Workers SDK.

This PR has been automatically closed because you are not currently a registered (vouched) collaborator for this repository.

AI tools now let our team generate proposed code changes quickly. Reviewing changes, checking that they solve the right problem, and maintaining code quality over time still take substantial care and effort. We therefore limit PRs to registered collaborators so we can focus that effort where it is most useful.

For the majority of external contributors, the most effective way to help is through issues: describing a problem or use case, providing a minimal reproduction, investigating its cause, or helping us verify a fix. Those contributions help us understand what needs to change and are very welcome.

We will take an initial look at this PR and decide whether it is something we want to invest time in reviewing and maintaining. We may reopen it if we decide to proceed, but we cannot guarantee that it will be reopened or receive a full review.

@github-actions github-actions Bot closed this Nov 20, 2026
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Nov 20, 2026
@workers-devprod
workers-devprod requested review from a team and petebacondarwin and removed request for a team November 20, 2026 15:11
@workers-devprod

workers-devprod commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 2 potential issues.

Devin Review

Comment thread .changeset/quiet-owls-evict.md Resolved
@github-project-automation github-project-automation Bot moved this from Done to Untriaged in workers-sdk Nov 20, 2026
@clanky-the-clanker

clanky-the-clanker Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

This pull request's reviews are posted as pull request reviews: see the review of 76dcfaea.

@pkg-pr-new

pkg-pr-new Bot commented Nov 20, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

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

@cloudflare/codemods

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

@cloudflare/config

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

@cloudflare/containers-shared

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/runtime-types

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 76dcfae

@petebacondarwin

Copy link
Copy Markdown
Contributor

clanker review

@clanky-the-clanker clanky-the-clanker Bot 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.

✅ Approved — No issues found. The fix to make dev control calls async and the header fix for failed calls are correct and covered by tests.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

The change only alters how dev-control calls are dispatched (sync or async) and which header is set when a call fails. It adds no new trust boundary, input handling or secrets.


📖 AGENTS.md: ✅ LGTM

The change does not affect the repository's agent guidance.


📋 Code Quality: ✅ LGTM

The async forcing for evictDurableObject/execDurableObjectSql on the Fetcher target is correct. Both methods already return Promises, so no caller depends on a synchronous result. The try/finally sets rpcAwaited on rejection, so the client receives the Promise result-type header and surfaces the real error. The new tests cover both paths with loose timing thresholds.


⚡ Performance: ✅ LGTM

Moving these calls off Atomics.wait() removes the main-thread freeze. It adds no new overhead.


📝 Documentation: ✅ LGTM

The changeset is present and the code comments explain why the change is needed.


Reviewed commit: 76dcfaea

Comment thread .changeset/quiet-owls-evict.md Resolved
@petebacondarwin
petebacondarwin enabled auto-merge (squash) November 23, 2026 15:04

@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

@petebacondarwin
petebacondarwin merged commit 5bc7dba into cloudflare:main Nov 23, 2026
169 of 172 checks passed
@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Nov 23, 2026
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Nov 23, 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.

Miniflare: unsafeEvictDurableObject() blocks the Node.js event loop and times out when the Durable Object is waiting on Node.js

3 participants