Skip to content

test(desktop): the unreachable-server test keeps its port - #2020

Merged
mbeisser1 merged 2 commits into
mainfrom
test/2002-unreachable-server-port
Oct 10, 2026
Merged

mbeisser1 merged 2 commits into
mainfrom
test/2002-unreachable-server-port

Conversation

@mbeisser1

@mbeisser1 mbeisser1 commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Bug Description

Expected: an_unreachable_server_is_reported_without_the_media_link in src-tauri/src/commands/download.rs (renamed a_server_that_hangs_up_is_reported_without_the_media_link here) passes on every run.

Actual: it failed once in four full src-tauri runs, when the request reached a live server.

Root Cause

The test bound 127.0.0.1:0, read the port, and released the listener before the request. Seven other tests in the crate start httpmock servers on ephemeral ports, so one of them could take the released port in between, and the request then reached that server instead of failing.

Fix Description

The test keeps its listener for its whole life. A thread accepts each connection and drops it at once, so the request fails immediately with "Could not reach the server", the port is never free for another test, and no timeout is involved. The assertions are unchanged. Test-only.

How to Reproduce (Before Fix)

  1. Run cargo test --manifest-path src-tauri/Cargo.toml several times.
  2. Occasionally another test's httpmock server takes the released port.
  3. The test fails because the error does not start with "Could not reach the server".

How to Verify (After Fix)

  1. cargo test --manifest-path src-tauri/Cargo.toml a_server_that_hangs_up passes in about 0.03 s.
  2. The full src-tauri suite passes (206 tests).
  3. Read the test: the listener is moved into a thread and never dropped before the request.

Impact Assessment

Regression Risk

None for the product: only a test changes. The accepting thread lives until the test process ends, which holds one port and one idle thread.

Checklist

  • Root cause identified and documented above
  • Fix addresses the root cause (not just symptoms)
  • Added test to prevent regression (the fix is the test itself)
  • Existing tests pass locally
  • Tested the specific reproduction steps

Related Issues

Closes #2002.

🤖 Generated with Claude Code

an_unreachable_server_is_reported_without_the_media_link bound a free
port, released it, and expected nothing to answer there. Another test in
the run could start an httpmock server on that port in between, and the
request then reached it. The listener now lives for the test's whole
life, with a thread that accepts each connection and drops it at once,
so the request fails immediately and no timeout is involved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mbeisser1 mbeisser1 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of #2020: Standards 2 findings (one has no line in the diff and follows in a top-level comment), Spec none, Correctness none.

Comment thread src-tauri/src/commands/download.rs Outdated
@mbeisser1

Copy link
Copy Markdown
Member Author

Finding with no line in the diff.

Standards · judgement (PR description): the checklist ticks "Added test to prevent regression", but the PR adds no test; it changes how an existing test holds its port. A ticked box that is false misleads a later reader. Fix: untick it and say the fix is the test itself.

Review of #2020: the server in the test now accepts and hangs up, so
the name says that rather than unreachable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mbeisser1
mbeisser1 marked this pull request as ready for review October 10, 2026 02:13
@mbeisser1

Copy link
Copy Markdown
Member Author

Standards · judgement (PR description): the checklist ticks "Added test to prevent regression", but the PR adds no test.

Fixed in the description: the box is unticked with "(the fix is the test itself)", and the description names the renamed test.

Review of #2020, closed out.

  • Standards: 2 findings (2 Fixed); re-review found nothing.
  • Spec: no findings.
  • Correctness: no findings (the reviewer ran the test binary alone 300 times with no failure); re-review found nothing.
  • Deferred: none. Declined: none. No commits for CI failures; no merges of the base. No user threads.

@mbeisser1
mbeisser1 merged commit 61a6a20 into main Oct 10, 2026
28 checks passed
@mbeisser1
mbeisser1 deleted the test/2002-unreachable-server-port branch October 10, 2026 02:26
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 desktop test: an_unreachable_server_is_reported_without_the_media_link can lose its free port

1 participant