Skip to content

fix(servers): bound port, force stop frees the port, one Stop-all summary (XR epic S4) - #70

Merged
aMonteSl merged 5 commits into
v1.2.1from
claude/project-thread-kvvyg6-servers
Nov 25, 2026
Merged

aMonteSl merged 5 commits into
v1.2.1from
claude/project-thread-kvvyg6-servers

Conversation

@aMonteSl

Copy link
Copy Markdown
Collaborator

Requested by Adrián · project thread

Story S4 of the XR environment review epic (audit in docs/xr-audit/launcher.md, PR #67).

What changes

  • Reported port = bound port. Both servers expose getListeningPort(); serverFactory and multiServerLauncher report it to the registry, the session, the URL and the port-change toast. Before, an HTTPS server could fall back to another port while the list and URL showed the requested one.
  • forceStop releases the port. It now calls server.close() and closeAllConnections() instead of only dropping the reference.
  • Port search follows the requested port (requestedPort+1 … +100, capped at 65535). The old search stopped at 8080, so a busy 8080 or higher failed every launch.
  • Port probe checks loopback too. isPortAvailable(port) with no host checks 0.0.0.0, 127.0.0.1 and ::1. On macOS and Windows, a port held on localhost only could pass the wildcard probe.
  • Registration failure stops the server. The launch returns Failed to register the server: … and no longer leaves an unlisted listener running.
  • Stop all servers. The prompt counts running servers only. One summary replaces the N "Server stopped" toasts, and it says how many servers did not shut down cleanly.
  • Auto-open failures are logged and no longer turn a successful launch into an error.
  • launchServer was split into small helpers, so the lint warning budget stays at 158.

Tests

  • npm test: 1065/1065 passed, lint at 158/158 warnings.
  • test:xr-harness: passed.
  • New tests in serverLifecycle.test.cjs: getListeningPort while running and after stop; forceStop closes the listener; a port held only on loopback is reported busy.
  • The launcher and stop-all goldens were regenerated. The diff only reorders the port log line, adds the search end and changes the registration-failure result.

Needs a manual check

The localhost and wildcard double-bind (LAUNCHER-13) only reproduces on macOS and Windows. CI runs the unit tests there, but a real launch while another program holds localhost:3000 still needs checking by hand.

CHANGELOG [1.2.1] → Fixed is updated.


Generated by Claude Code

…all summary

- The launcher reports the port the server actually listens on
  (getListeningPort), so the HTTPS port in the list and URL matches.
- forceStop closes the listener and its connections instead of only
  dropping the reference, so the port is released.
- Port search follows the requested port (+100) instead of stopping
  at 8080; the host-less probe checks the wildcard and loopback.
- A server that cannot be registered is stopped and the launch fails.
- Stop all: counts running servers and shows a single summary.

Part of the XR environment review epic (S4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FkKtAtQus8TVjhG9bhytC
…nto claude/project-thread-kvvyg6-servers
The lifecycle tests stub the port search but read the real availability of
port 4000: on a machine where it was busy they passed, on a clean CI runner
the server kept 4000, the requests went to the stubbed port and the test
failed. With every suite in one process, the server it left listening then
hung the whole run. The requested port now always reads as busy, and the
unit runner passes --test-force-exit so a leaked handle fails fast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FkKtAtQus8TVjhG9bhytC
…nto claude/project-thread-kvvyg6-servers

# Conflicts:
#	apps/vscode-extension/CHANGELOG.md
@aMonteSl
aMonteSl merged commit fb77086 into v1.2.1 Nov 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants