Skip to content

test: skip a loopback port a plain TCP socket holds - #963

Merged
Blind-Striker merged 1 commit into
masterfrom
fix/956-listener-port-held-by-tcp
Nov 22, 2026
Merged

Blind-Striker merged 1 commit into
masterfrom
fix/956-listener-port-held-by-tcp

Conversation

@Blind-Striker

Copy link
Copy Markdown
Collaborator

📝 Description

What does this PR do?

The loopback upgrade listener used by the client-hosted MCP and terminal tests reserves a free port, releases it, and then registers an HTTP.sys prefix. On Windows it retried the next reserved port only for error 183, an HTTP.sys prefix conflict. If a plain TCP socket took the port between those steps, HttpListener.Start failed with error 32 (ERROR_SHARING_VIOLATION), and the test that needed the listener failed.

  • The helper now treats 32 like 183 on Windows: it tries the next reserved port, within the same five attempts and with the same exhaustion message.
  • A new test holds a port with a plain socket:
    • On Windows, it asserts the error-32 precondition directly, then that the helper starts on the next port.
    • Elsewhere, it asserts that the failure propagates, without pinning an OS-specific code.
  • The existing conflict test and the new one share one private helper for the start-on-the-next-port assertions. The existing test keeps its expected values, including its off-Windows 400 check.

Tests only: no production code changes.

Related Issue(s):

Closes #956

🔄 Type of Change

  • 🧪 Test improvements

🎯 Protocol & API Surface

  • No public API change
  • No generated output changed
  • The pinned snapshot (spec/) is untouched
  • Nothing under external/ was hand-edited

🧪 Testing

  • Red proof: with the old 183-only filter, the new test fails on net10.0 and net11.0. The failure is at its oracle: HttpListenerException: The process cannot access the file because it is being used by another process.
  • With the fix: the focused listener, terminal handshake and client-hosted MCP classes pass on net10.0, net11.0 and net472.

✅ Completion Gate

  • The local check in quality-gates.md passes on the head rebased onto master: whitespace, format/style, clones, slopwatch, the release build, all test projects, the API snapshots, generate --verify, the fixed point, Extensions and Native AOT.

✅ Code Quality Checklist

  • No new analyzer warnings, and no new suppressions
  • No tests skipped or weakened; one existing test was restructured onto the shared helper with unchanged expectations
  • Branch is up to date with the target branch, no merge conflicts
  • Commit messages carry no AI-attribution trailers

🔍 Additional Notes

Breaking Changes: none. Dependencies: none. CHANGELOG: none; tests only.

@Blind-Striker
Blind-Striker force-pushed the fix/956-listener-port-held-by-tcp branch from a8b1f70 to 9838741 Compare November 22, 2026 10:05
@Blind-Striker
Blind-Striker marked this pull request as ready for review November 22, 2026 10:05
@Blind-Striker
Blind-Striker added this pull request to the merge queue Nov 22, 2026
Merged via the queue into master with commit 0774411 Nov 22, 2026
15 checks passed
@Blind-Striker
Blind-Striker deleted the fix/956-listener-port-held-by-tcp branch November 22, 2026 10:29
@Blind-Striker Blind-Striker mentioned this pull request Nov 22, 2026
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.

Flaky on Windows net11.0: the loopback upgrade listener fails with error 32 when a TCP socket takes its reserved port

1 participant