Commit 8280619
authored
fix(dev): take the next registered port when 3000 is busy (#159)
* fix(dev): take the next registered port when 3000 is busy
`npm run dev` refused to start when port 3000 was in use, telling the
user to free it or re-provision against another port. Provisioning
already registers an OAuth callback for every port from 3000 to 3009,
precisely so a forwarded dev server can land anywhere in that range and
still log in, so refusing was throwing away a fallback the backend was
built to support.
The dev server now takes the first free port in the range and prints
where it landed. A PORT named in the environment is left alone: that one
is a decision, so a busy one is still an error.
Two guards get more accurate as a result:
- The callback check no longer fails when OAUTH_CALLBACK names 3000 and
the server runs on 3005. Both are registered, so login works.
- Running out of ports is now its own message, rather than being
reported as "port 3000 is in use".
The port list lives in scripts/lib.mjs and is asserted against the
`range()` call in drupal/.devtools/provision, so widening it on one side
fails the tests rather than breaking login on the other.
* fix(dev): refuse a frontend port with no registered OAuth callback
`PORT=4000 npm run dev` started fine and then failed only at login. The
browser builds its callback from the port it is on, and Drupal registers
3000-3009 plus whatever OAUTH_CALLBACK names, so 4000 was rejected as
invalid_client with the rest of the site working - the exact failure
mode the other guards in this script exist to prevent.
The guard now asks whether anything registers the port, rather than
whether OAUTH_CALLBACK happens to name it. A backend this repo did not
provision is left alone: its consumer was registered somewhere this
checkout cannot see, so `backendIsProvisionedHere` gates the check.
Port selection also moves to the last step before Nuxt starts. Nuxt 2
answers a bind failure with a random port, so nothing can fully close
the gap between finding a port free and Nuxt taking it, but none of the
configuration checks need the port, and running them first makes the gap
as small as this script can make it.
The test backend now answers the OAuth check the way a provisioned
Drupal does, so the port cases run through the whole script instead of
stopping at the consumer check.1 parent 745fd92 commit 8280619
6 files changed
Lines changed: 379 additions & 48 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
95 | 104 | | |
96 | 105 | | |
97 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
153 | 171 | | |
154 | 172 | | |
155 | 173 | | |
| |||
198 | 216 | | |
199 | 217 | | |
200 | 218 | | |
201 | | - | |
| 219 | + | |
202 | 220 | | |
203 | 221 | | |
204 | 222 | | |
| |||
210 | 228 | | |
211 | 229 | | |
212 | 230 | | |
213 | | - | |
| 231 | + | |
214 | 232 | | |
215 | 233 | | |
216 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
| 19 | + | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
20 | 32 | | |
21 | 33 | | |
22 | | - | |
| 34 | + | |
23 | 35 | | |
24 | 36 | | |
25 | 37 | | |
26 | | - | |
| 38 | + | |
27 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
28 | 48 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
32 | 52 | | |
33 | 53 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
45 | 96 | | |
46 | 97 | | |
47 | 98 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
51 | 109 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 110 | + | |
| 111 | + | |
55 | 112 | | |
56 | 113 | | |
57 | 114 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
62 | 118 | | |
63 | 119 | | |
64 | 120 | | |
65 | | - | |
66 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
67 | 135 | | |
68 | 136 | | |
69 | 137 | | |
70 | 138 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
77 | 146 | | |
78 | 147 | | |
79 | 148 | | |
80 | 149 | | |
81 | | - | |
| 150 | + | |
82 | 151 | | |
83 | | - | |
84 | | - | |
| 152 | + | |
85 | 153 | | |
86 | 154 | | |
87 | 155 | | |
88 | 156 | | |
89 | 157 | | |
90 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
91 | 163 | | |
92 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
93 | 168 | | |
94 | 169 | | |
95 | 170 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
228 | 264 | | |
229 | 265 | | |
230 | 266 | | |
| |||
0 commit comments