Skip to content

fix(miniflare): reject loopback bind failures during startup - #15485

Merged
petebacondarwin merged 2 commits into
cloudflare:mainfrom
RealBhupesh:fix/miniflare-loopback-bind-error
Sep 8, 2026
Merged

petebacondarwin merged 2 commits into
cloudflare:mainfrom
RealBhupesh:fix/miniflare-loopback-bind-error

Conversation

@RealBhupesh

@RealBhupesh RealBhupesh commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Attach an error listener before listen in #startLoopbackServer so loopback bind failures reject ready instead of becoming uncaught exceptions.
  • Guard #stopLoopbackServer when the loopback server never started so dispose() still settles after a startup failure.
  • Clear cached loopback server/host after a successful stop so setOptions() can recover when a host update fails to bind.
  • Add regression tests for startup bind failure and setOptions recovery.

Fixes #15466

Test plan

  • vitest run -t "rejects ready when loopback server cannot bind"

  • vitest run -t "setOptions: recovers after loopback bind failure"

  • Tests included/updated

  • Documentation not necessary because: internal Miniflare error-handling fix with no user-facing API or docs changes.

Attach an error listener before listen in #startLoopbackServer so bind
failures reject ready instead of becoming uncaught exceptions. Guard
#stopLoopbackServer when the loopback server never started so dispose
still settles after a startup failure.

Fixes cloudflare#15466
@changeset-bot

changeset-bot Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3f0340c

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-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-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Sep 3, 2026
@workers-devprod
workers-devprod requested review from a team and edmundhung and removed request for a team September 3, 2026 10:58
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/miniflare-loopback-bind-error.md: [@cloudflare/wrangler]
  • packages/miniflare/src/index.ts: [@cloudflare/wrangler]
  • packages/miniflare/test/index.spec.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

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

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

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

@cloudflare/codemods

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

@cloudflare/config

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 3f0340c

Clear #loopbackServer and #loopbackHost after a successful stop so a failed
bind during setOptions does not leave a stopped server cached. Add regression
test for recovery after an unbindable host update.
@petebacondarwin
petebacondarwin removed the request for review from edmundhung September 8, 2026 17:01
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @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

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Sep 8, 2026
@petebacondarwin
petebacondarwin merged commit fea3cd0 into cloudflare:main Sep 8, 2026
63 of 64 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Sep 8, 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] Loopback bind errors are uncaught and leave ready/dispose pending

3 participants