Skip to content

[miniflare] Start runtime disposal before browser/proxy cleanup - #15143

Merged
petebacondarwin merged 4 commits into
cloudflare:mainfrom
teamleaderleo:source/miniflare-runtime-settlement-clean
Aug 15, 2026
Merged

petebacondarwin merged 4 commits into
cloudflare:mainfrom
teamleaderleo:source/miniflare-runtime-settlement-clean

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #15085.

Miniflare.dispose() currently waits for browser/proxy cleanup before calling Runtime.dispose(), so either cleanup can delay or skip the workerd termination request.

This starts Runtime.dispose() first, which requests workerd termination before those cleanup awaits. Browser cleanup → exit-hook removal → proxy cleanup keeps the same order.

If browser/proxy cleanup fails, Miniflare.dispose() remembers that error, waits for the already-started runtime exit, continues the remaining cleanup, then returns the cleanup error.

Tests cover:

  • requesting workerd termination while proxy cleanup is still pending;
  • keeping Miniflare.dispose() pending on a proxy cleanup failure until the runtime exit settles.
  • continuing the remaining cleanup after a proxy cleanup failure.

  • 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 changes internal teardown ordering without changing the public API.

A picture of a long-eared jerboa
image

@changeset-bot

changeset-bot Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2dc853e

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

This PR includes changesets to release 8 packages
Name Type
miniflare Patch
@cloudflare/deploy-helpers Patch
@cloudflare/pages-shared Patch
@cloudflare/remote-bindings Patch
@cloudflare/runtime-types Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers 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 petebacondarwin and removed request for a team August 12, 2026 02:01
@workers-devprod

workers-devprod commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

@teamleaderleo teamleaderleo changed the title [miniflare] Start runtime disposal before independent cleanup [miniflare] Start runtime disposal before browser/proxy cleanup Aug 12, 2026
@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Aug 12, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

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

@cloudflare/config

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 2dc853e

@petebacondarwin
petebacondarwin force-pushed the source/miniflare-runtime-settlement-clean branch from 1277272 to 63fc4a8 Compare August 14, 2026 16:13
Comment thread packages/miniflare/src/index.ts Outdated

@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 2e0c962 into cloudflare:main Aug 15, 2026
65 of 68 checks passed
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Aug 15, 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.dispose() can delay or skip workerd termination behind earlier cleanup awaits

3 participants