dev-server.sh: a global pidfile makes one worktree claim another's server #54
Labels
No labels
area:defold
area:docs
area:infra
area:protocol
area:testing
kind:bug
kind:chore
phase:breadth
phase:core
phase:hardening
phase:slice
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
yuris/spacetimedb-defold#54
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while working PR #53 (release-gate archive fixes), not fixed there — out of scope, and adjacent to #50.
Symptom
dev/tools/dev-server.shreportedserver already running at http://127.0.0.1:5701 (pid 3339071)when that pid was actually serving port 3000, then failed to connect.Root cause
Two things combine:
dev-server.sh:26defaultsSTATEto a global/tmp/spacetimedb-defold, not a per-worktree path. So every worktree and every concurrent invocation shares one pidfile.server_pid()at:36-42only doeskill -0on the recorded pid. It never checks that the process is serving this$PORT.So a live server on any port satisfies the check for a request about any other port, and the script reports a server that is not there.
Why it matters now
This bit three separate agents during the #24 push, each working a different branch in its own worktree. The workaround is always
STDB_STATE_DIR, and every harness invocation in this repo now sets it — but the default is the trap, and a contributor with one checkout will hit it the first time they run two ports.#50 hardened the readiness half of this script (the port answering is not proof our server is the one answering) and moved the stray-server refusal ahead of the spawn. This is the same class of bug one level up: the pidfile is not proof either.
Fix
Either derive
STATEfrom$PORTso pidfiles cannot collide, or haveserver_pid()verify the recorded pid actually holds$PORT—ss -ltnpalready gives that, and:80-82reads it for the stray-server message.The second is smaller and closes the case where two ports legitimately want two servers. #50's own comment makes the argument: "A ready port is not proof OUR server is the one answering." A live pid is not proof it is ours either.
Not blocking
dev/is export-ignored, so this is harness ergonomics, not shipped behaviour. Not a v1.0 blocker.