Skip to content

make Miniflare inspector proxy more resilient to selecting a free port#11202

Merged
petebacondarwin merged 9 commits intomainfrom
pbd/miniflare/inspector-port-resilience
Nov 11, 2025
Merged

make Miniflare inspector proxy more resilient to selecting a free port#11202
petebacondarwin merged 9 commits intomainfrom
pbd/miniflare/inspector-port-resilience

Conversation

@petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Nov 6, 2025

We have seen some test flakes when there are a lot of Miniflare instances running in parallel. This appears to be that there is a small chance that a port becomes unavailable between checking if it is free and using it.


  • Tests
    • Tests included
    • Tests not necessary because: time will tell if we don't get any more flakes!
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal refactoring
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: inspector-proxy-worker is not part of v3

@petebacondarwin petebacondarwin requested a review from a team as a code owner November 6, 2025 16:16
@changeset-bot
Copy link

changeset-bot bot commented Nov 6, 2025

🦋 Changeset detected

Latest commit: fb82aff

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 6, 2025

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: fb82aff

@petebacondarwin petebacondarwin force-pushed the pbd/miniflare/inspector-port-resilience branch 5 times, most recently from 404df74 to 23f2d75 Compare November 8, 2025 12:05
try {
const port = await this.#getInspectorPortToUse();
this.log.debug("Trying to listen on port: " + port);
server.listen(port, () => listening.resolve());
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this throw synchronously?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Urgh! I think you are right. If the port is taken then it calls the callback with an error parameter...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually the callback never gets an arg, which is what led me to believe it would throw. Instead you have to add an error handler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@petebacondarwin petebacondarwin force-pushed the pbd/miniflare/inspector-port-resilience branch from 23f2d75 to f7c0089 Compare November 10, 2025 14:17
@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Nov 11, 2025
@petebacondarwin petebacondarwin merged commit 305ffb3 into main Nov 11, 2025
40 of 45 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Nov 11, 2025
@petebacondarwin petebacondarwin deleted the pbd/miniflare/inspector-port-resilience branch November 11, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants