Bind serve's socket before writing client.json

A serve that lost the port race had already signed in, so client.json
named a port another engine held and every client talked to that one.
The socket is now bound first and handed to uvicorn.
This commit is contained in:
2026-09-16 16:47:11 +02:00
parent 42ea2e50ac
commit f950cfbf6c
3 changed files with 70 additions and 13 deletions
+2 -1
View File
@@ -53,7 +53,8 @@ The default port moves out of the way when something already has it (8001,
8002, and so on) and says which one it took; the URL written to
`client.json` is the one it is actually on. A port you *asked* for is never
moved off: `--port 9000` on a taken 9000 fails, because something else is
there and you named it.
there and you named it. It fails before `client.json` is written, so every
client keeps talking to the engine that is actually up.
What it will *not* do is start a second engine for the same instance. Before
anything else, `serve` looks for an engine already serving this directory —