Skip to content

Commit c8fac5c

Browse files
cliffhallclaude
andcommitted
fix: refuse an occupied port in the HTTP smoke, and fail on a wait timeout
Copilot round 9 on #4921. A listener already on the port would have answered the readiness probe and been tested in place of the new build. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent bf8a1c8 commit c8fac5c

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

‎.claude/skills/client-smoke/SKILL.md‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,29 @@ the URL. The transport is inferred from the path: `/mcp` is Streamable HTTP,
130130

131131
```sh
132132
(
133+
URL=http://localhost:3917/mcp
134+
# Refuse a port something already answers on: it would be tested instead of this build.
135+
curl -s -o /dev/null "$URL" && { echo "port 3917 is already in use" >&2; exit 1; }
133136
PORT=3917 node src/everything/dist/index.js streamableHttp >/dev/null 2>&1 &
134137
SERVER_PID=$!
135138
trap 'kill "$SERVER_PID" 2>/dev/null' EXIT # stops it however the subshell ends
139+
READY=
136140
for _ in $(seq 50); do # at most ten seconds
137-
curl -s -o /dev/null http://localhost:3917/mcp && break
138141
kill -0 "$SERVER_PID" 2>/dev/null || { echo "server exited before listening" >&2; exit 1; }
142+
curl -s -o /dev/null "$URL" && { READY=1; break; }
139143
sleep 0.2
140144
done
141-
$INSPECT http://localhost:3917/mcp \
142-
--method tools/call --tool-name echo --tool-arg message=over-http --format json
145+
[ -n "$READY" ] || { echo "server did not listen within ten seconds" >&2; exit 1; }
146+
$INSPECT "$URL" --method tools/call --tool-name echo --tool-arg message=over-http --format json
143147
)
144148
```
145149

146-
Each part of that is there for a failure it prevents. Without the wait, the CLI
147-
can reach the port before the server is listening and exit 4. The wait is
148-
bounded and checks that the server is still alive, so a server that fails to
149-
bind (the port is taken, the build is missing) ends the run instead of hanging
150-
it. The subshell's `EXIT` trap stops the server by pid even when the CLI call
150+
Each part of that is there for a failure it prevents. The first check refuses
151+
a port that already answers, because a stale listener there would be the
152+
server under test. Without the wait, the CLI can reach the port before the
153+
server is listening and exit 4. The wait is bounded and checks that this
154+
server is still alive, so one that fails to bind (the build is missing, the
155+
port was taken in between) ends the run instead of hanging it. The subshell's `EXIT` trap stops the server by pid even when the CLI call
151156
fails; a listener left on the port makes the next run talk to the old build.
152157
By hand in two terminals, the equivalent is waiting for the `listening on
153158
port` line and stopping the server with Ctrl-C.

0 commit comments

Comments
 (0)