Commit 69d3624
committed
fix(bridge): use OS-assigned port for auto-started web servers
tryStartWebServer used findFreePort to walk from coordinatorPort+1
(19877), which has a TOCTOU race — it probes, closes the probe, then
the caller binds. Between close and bind, a concurrent agent grabs the
same port. This caused EADDRINUSE when parallel subagents all started
web servers simultaneously.
Port 0 eliminates the race: the OS atomically assigns a unique free
port for each listener. The PWA discovery path (probe from 19877) is
only used when the page is served from a non-local host (e.g. GitHub
Pages). When served locally (the bridge-started case), the browser
connects via location.host directly — the port number doesn't need to
be predictable.
Remove the coordinatorPort parameter from tryStartWebServer — it was
only used to compute the scan base, which is no longer needed.1 parent 6b44305 commit 69d3624
2 files changed
Lines changed: 12 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
| |||
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
104 | | - | |
105 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
106 | 113 | | |
107 | 114 | | |
108 | 115 | | |
109 | | - | |
110 | 116 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 117 | + | |
115 | 118 | | |
116 | 119 | | |
117 | 120 | | |
| |||
0 commit comments