You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
workerd CI scenarios can fail when wrangler's port is taken before it binds #54
The Cloudflare workerd job failed once on PR #53 (run 38468041845) in the end-tls scenario, before any library code ran:
Fatal uncaught kj::Exception: ... ::bind(...): Address already in use; toString() = 127.0.0.1:40039
Address already in use (127.0.0.1:40039). Please check that you are not already running a server on this address or specify a different port with --port.
The rerun passed. The change under test does not touch the workerd scenarios.
Cause
tests-startup/workerd-run.mjs chooses ports with freePort() (lines 36–41): it listens on port 0, reads the port, closes the listener, and later passes the number to wrangler dev --port. Anything can take the port in between, including processes from the previous scenario that are still shutting down. Lines 67–68 also choose the main and inspector ports with two separate calls, so both can get the same number.
Options
Retry a scenario once when wrangler's output contains Address already in use, with fresh ports.
Choose both ports while holding the first listener open, so they cannot be equal, and wait for the previous scenario's process group to exit before starting the next.
Let wrangler choose the port and read it from its output, if wrangler 4 reports it reliably.
A retry is the smallest change and also covers ports taken by unrelated processes.
PR #150 chose both ports while holding the first listener open and retried once on Address already in use. PR #151 goes further: the runner now uses Wrangler's createTestHarness() (Cloudflare's recommended integration-test API), one harness per build and compatibility date, reset before each scenario. There are no wrangler dev processes or chosen ports left, so this race cannot recur. Closes when #151 lands.
Activity
test(workerd): run scenarios through Wrangler's createTestHarness
okomarov commentedon Oct 18, 2026
PR #150 chose both ports while holding the first listener open and retried once on
Address already in use. PR #151 goes further: the runner now uses Wrangler'screateTestHarness()(Cloudflare's recommended integration-test API), one harness per build and compatibility date, reset before each scenario. There are nowrangler devprocesses or chosen ports left, so this race cannot recur. Closes when #151 lands.test(workerd): run both builds through Wrangler's createTestHarness a…