#537
fix(proxy): stop serving routes whose owner has died
Problem
The daemon serves a route cache that only refreshes when routes.json changes, and loadRoutes drops dead owners only while loading. When an app's portless process is killed with SIGKILL it never touches the file, so its hostname keeps forwarding to the old port until some other route changes.
Changes
- The proxy checks the owner of the route a lookup resolves to, for HTTP requests, WebSocket upgrades and HTTP/2 extended CONNECT. A dead owner is skipped, so a wildcard request falls through to the next eligible parent, and the 404 page no longer lists it.
- Same policy as
loadRoutesandprune, now one sharedisRouteOwnerAlive: static aliases (pid 0) stay, and a process portless can't signal still counts as running (#498). - Nothing is written to
routes.jsonand no process is killed. - Only the matched route is probed, so the cost is one
process.kill(pid, 0)per request however many routes exist. Filtering the whole table per request cost about +80 µs at 50 routes and +565 µs at 200.
Closes #534. Complements #383, which prunes the file on a timer.
Visual proof
portless myapp node server.js, then kill -9 on the portless process (the dev server survives):
main this branch
curl myapp.localhost 200 200
kill -9 <portless pid>
curl myapp.localhost 200 404
routes.json lists it yes yesWritten by an AI agent (Claude) on behalf of @jasonkuhrt.
@jasonkuhrt is attempting to deploy a commit to the Vercel Labs Team on Vercel.
A member of the Team first needs to authorize it.