Skip to content

test(tcp): give the TCP service its own free port, not the HTTP port + 1 - #312

Merged
andrevanzuydam merged 1 commit into
v3from
fix/raw-tcp-test-free-port
Nov 13, 2026
Merged

andrevanzuydam merged 1 commit into
v3from
fix/raw-tcp-test-free-port

Conversation

@andrevanzuydam

@andrevanzuydam andrevanzuydam commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Flake. test_listen_accept_in_process_while_http_still_serves failed on tina4-python#311, whose change never touches TCP:

attempt 1/3 (port 48443): never became ready on port 48443 in 25.0s
... tcp_service 'trackers' port 48444 is already bound by another worker — single-owner, this worker will not bind

Both raw-TCP contract tests set TINA4_TCP_PORT to the HTTP port plus one and never checked that port was free. When something on the runner held it, the framework did the right thing and refused to bind, and the readiness wait for that port timed out.

Fix (test-only). _tcp_port_env() allocates the TCP port with the suite's own free_port() on every boot attempt (never the HTTP port itself) and hands the same port to the readiness check and the client. The framework's single-owner behaviour is unchanged.

Checks. The file collects (21 tests). ruff reports the same 12 findings as v3 (E702 semicolons, none on changed lines), so this change adds none. These tests need POSIX process groups, so CI on Linux is where they run; this PR's CI is the proof.

🤖 Generated with Claude Code

Two raw-TCP contract tests derived the TCP service port as the HTTP port
plus one and never checked it was free. On a busy CI runner it sometimes
was not: the framework correctly refused it ("tcp_service 'trackers' port
48444 is already bound by another worker -- single-owner, this worker will
not bind") and the readiness wait ran out after 25s ("child server never
became ready"). Seen on tina4-python#311, whose change does not touch TCP.

_tcp_port_env() takes a real free_port() per boot attempt (never the HTTP
port itself) and hands the readiness check and the client the same one.
Test-only; the framework's single-owner behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Tina4 <82961293+tina4stack@users.noreply.github.com>
Signed-off-by: Andre van Zuydam <andrevanzuydam@gmail.com>
@andrevanzuydam
andrevanzuydam merged commit 0193ca6 into v3 Nov 13, 2026
14 checks passed
@andrevanzuydam
andrevanzuydam deleted the fix/raw-tcp-test-free-port branch November 13, 2026 11:24
@andrevanzuydam andrevanzuydam mentioned this pull request Nov 13, 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.

1 participant