Two `wrangler dev` processes started together pick the same inspector port
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Start with packages/wrangler/src/api/startDevWorker/ConfigController.ts, especially resolveInspectorConfig, and trace how the inspector port is selected and passed to workerd. Reproduce the race using the linked repro, which starts two wrangler dev processes together with separate --port values. Done means concurrent starts avoid the inspector port collision or report the inspector address and --inspector-port accurately.
Written by the indexing model from the issue text.
Description
What versions & operating system are you using?
wrangler 4.163.0 (miniflare 5.20261116.0-beta, workerd 1.20261116.1), Node 24.21.0, Linux x64.
Please provide a link to a minimal reproduction
https://github.com/onmax/repros/tree/repro/wrangler-inspector-port-race/wrangler-inspector-port-race
Describe the Bug
When two wrangler dev processes start at the same moment, each with its own --port, both pick inspector port 9229 and one of them fails:
✘ [ERROR] Address already in use (socket "direct:1:default"). Please check that you are not already running a server on this address or specify a different port with --port.
This happens in scripts that serve two builds side by side, like a before/after benchmark. The repro starts two Workers together, five times in a row. Every run leaves one process that never answers (6/6 on my machine). Passing a distinct --inspector-port to each (CONTROL=1 pnpm verify) fixes it, 0/4. Started a few seconds apart, the second process moves to 9230 as expected.
The cause looks like a check-then-bind race. resolveInspectorConfig asks get-port for a free port from 9229 up. get-port binds the port, closes it, and returns the number. workerd binds it later, so both processes get 9229 in that window.
The error message makes it harder to find. direct:1:default is the inspector proxy's socket, but nothing says so, and the hint suggests --port, which is already different for each process. Naming the inspector address and --inspector-port in the message would point people to the fix.
Please provide any relevant error logs
See above. With CONTROL=1 both processes start in every run.
- Dominant language
- TypeScript
- Stars
- 4.7k
- Forks
- 1.7k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 282
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/workers-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
cloudflare/workers-sdk#17215 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
cloudflare/workers-sdk#17189 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/workers-sdk#17187 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
cloudflare/workers-sdk#17175 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
cloudflare/workers-sdk#17174 ·
Maintainers usually reply within 1 day
All issues in cloudflare/workers-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
earendil-works/pi#12615 ·
Maintainers usually reply within 1 day
-
My Caps shows "Shared" on private Caps that were never sharedPossibly taken @AksharP5 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CapSoftware/Cap#4569 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
OHDSI/Data2Evidence#3749 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Flagsmith/flagsmith-nodejs-client#332 ·
Maintainers usually reply within 2 days