pub fn allocate(
workers: &[String],
base_port: Option<u16>,
opts: &DevOptions,
) -> Vec<Serving>Expand description
Allocate a port per worker (#552): wrangler dev binds one port per process,
so serving N contexts means N distinct ports, assigned base + i over the
deterministic worker order.
The one exception preserves the pre-#552 contract: a lone worker with no
explicit --base-port gets None — no injected --port at all — so it
lands on wrangler’s own default and -- --port N still works. Injecting
unconditionally would break that, because a repeated --port is a hard
wrangler error, not last-wins.
Inspector ports follow the same shape, from --inspect-port. They are
allocated under --inspect, and also whenever more than one worker is
served (#1954): wrangler dev always starts its inspector, on 9229 unless
told otherwise, so N wranglers started together all bind 9229 and every one
but the first dies with Address already in use. A lone worker without
--inspect gets none, keeping its invocation byte-for-byte as before.