Commit bafabae
fix: a deploy that changes nothing, and a /health field that names the wrong hop
Twelve findings from the review of this PR, plus one raised by cswap's pin
against the fix for the last of them. Each has a test that dies when its fix is
reverted.
THE DEPLOY ONES, which is why this is not a tidy-up:
otherHolderOn() compared process AGE only. Every incumbent outlives a process
that just started, so on every deploy the NEW code judged itself surplus, exited
0, and the OLD holder kept serving with nothing saying so. Now a holder is a
duplicate only when it is running the same code.
holderPidOn() answered "holder" on the mere presence of a run-service, which
made runningOurCode() unreachable: the holder always keeps a descriptor to the
listening socket, so the loop always returned before the fingerprint branch.
bindFailed() read no error code, so a bind that can NEVER work — an address not
on this host, a privileged port — took the "someone else has it" path, found no
incumbent to ask, and exited 0. A deploy that started nothing reported success.
Bind errors also carried libuv's errno through two hardcoded literals that named
EADDRINUSE and called everything else EACCES; util.getSystemErrorName is right
on both platforms and for every code.
The holder matched its child's release announcement against a RAW CHUNK while
the port line beside it was line-buffered. A chunk boundary inside "(handed
off)" reads a handover as a plain release, so the holder reclaims the port from
the successor already serving on it and spawns a second — the failure the
(handed off) marker exists to prevent, re-entered through the marker itself.
Ownership probes asked lsof about 127.0.0.1 while the bind honoured
CACHE_FIX_PROXY_BIND. Under any other address the probe matched nothing.
CACHE_FIX_PROXY_PORT=0 was rewritten to the legacy 9801 by `Number(env) || 9801`
("0" is a truthy string), while proxy/config.mjs read the same variable with
envInt and yielded 0.
THE SHUTDOWN ONES:
shutdown() had no re-entry guard although it is bound to SIGTERM, SIGINT and
SIGHUP, and a control-group stop delivers more than one. Each entry can put
another successor on fd 3. The window only exists while something is draining,
which a live session always is.
handle.close() always rejected on that path, because shutdown() closes the
server one line earlier and the second close reports ERR_SERVER_NOT_RUNNING.
Only the process.exit() inside .finally() beat the unhandled-rejection report.
THE HOP ONES:
/health.https_proxy published a configured candidate. resolveHop() falls
THROUGH the chain, so it named ":8118" while CONNECTs left via the second
fallback or via nothing at all. It now publishes the hop a resolve actually
used, and null when the chain was checked and found dead.
cswap's pin raised that the fix left one field carrying two meanings — a URL is
either measured or merely configured and a reader cannot tell. Split into
https_proxy_measured, and direct_last: a sticky ISO instant of the last direct
fall-through, under the name and for the reason the pin uses. A chain flaps back
within ~1s, so a point-in-time field cannot report the outage that happened.
hopAlive() and parseProxy() defaulted an https:// hop with no explicit port to
80, so a live TLS hop read as dead and the chain fell through past it.
CONNECT fell open to a direct dial with no way to refuse. Fail-open stays the
default on both ends of the chain — a hop restarting is back in ~1s and refusing
strands a session whose HTTPS_PROXY was baked at exec — but CACHE_FIX_REQUIRE_HOP=1
now exists for a deployment where the hop is a policy boundary rather than a cache.
Ref cnighswonger#304
Co-Authored-By: Claude <noreply@anthropic.com>1 parent a1fef09 commit bafabae
9 files changed
Lines changed: 695 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
155 | | - | |
156 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
157 | 163 | | |
158 | 164 | | |
159 | 165 | | |
| |||
347 | 353 | | |
348 | 354 | | |
349 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
350 | 363 | | |
351 | 364 | | |
352 | 365 | | |
353 | 366 | | |
354 | 367 | | |
355 | 368 | | |
356 | 369 | | |
357 | | - | |
| 370 | + | |
358 | 371 | | |
359 | 372 | | |
360 | 373 | | |
| |||
366 | 379 | | |
367 | 380 | | |
368 | 381 | | |
369 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
370 | 388 | | |
371 | 389 | | |
372 | 390 | | |
373 | 391 | | |
374 | | - | |
| 392 | + | |
375 | 393 | | |
376 | 394 | | |
377 | 395 | | |
| |||
437 | 455 | | |
438 | 456 | | |
439 | 457 | | |
440 | | - | |
| 458 | + | |
441 | 459 | | |
442 | 460 | | |
443 | 461 | | |
| |||
452 | 470 | | |
453 | 471 | | |
454 | 472 | | |
455 | | - | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
456 | 481 | | |
457 | 482 | | |
458 | 483 | | |
| |||
526 | 551 | | |
527 | 552 | | |
528 | 553 | | |
529 | | - | |
530 | | - | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
531 | 563 | | |
532 | 564 | | |
533 | 565 | | |
| |||
869 | 901 | | |
870 | 902 | | |
871 | 903 | | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
878 | 914 | | |
879 | 915 | | |
880 | 916 | | |
881 | 917 | | |
882 | 918 | | |
883 | | - | |
| 919 | + | |
884 | 920 | | |
885 | 921 | | |
886 | 922 | | |
| |||
889 | 925 | | |
890 | 926 | | |
891 | 927 | | |
892 | | - | |
| 928 | + | |
893 | 929 | | |
894 | 930 | | |
895 | 931 | | |
| |||
900 | 936 | | |
901 | 937 | | |
902 | 938 | | |
903 | | - | |
904 | | - | |
| 939 | + | |
905 | 940 | | |
906 | | - | |
| 941 | + | |
907 | 942 | | |
908 | 943 | | |
909 | 944 | | |
| |||
912 | 947 | | |
913 | 948 | | |
914 | 949 | | |
915 | | - | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
916 | 965 | | |
917 | 966 | | |
918 | 967 | | |
| |||
1022 | 1071 | | |
1023 | 1072 | | |
1024 | 1073 | | |
1025 | | - | |
| 1074 | + | |
1026 | 1075 | | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
1027 | 1086 | | |
1028 | 1087 | | |
1029 | 1088 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
245 | 248 | | |
246 | 249 | | |
247 | 250 | | |
| |||
262 | 265 | | |
263 | 266 | | |
264 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
265 | 280 | | |
266 | 281 | | |
267 | 282 | | |
| |||
272 | 287 | | |
273 | 288 | | |
274 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
275 | 295 | | |
276 | 296 | | |
277 | 297 | | |
| |||
321 | 341 | | |
322 | 342 | | |
323 | 343 | | |
| 344 | + | |
324 | 345 | | |
325 | 346 | | |
326 | 347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
402 | 428 | | |
403 | 429 | | |
404 | 430 | | |
| |||
897 | 923 | | |
898 | 924 | | |
899 | 925 | | |
900 | | - | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
901 | 935 | | |
902 | 936 | | |
903 | 937 | | |
| |||
1220 | 1254 | | |
1221 | 1255 | | |
1222 | 1256 | | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
1223 | 1264 | | |
| 1265 | + | |
| 1266 | + | |
1224 | 1267 | | |
1225 | 1268 | | |
1226 | 1269 | | |
| |||
0 commit comments