Skip to content

Test harness stub hard-codes port 8787, flaking under concurrent runs #72

Description

@justin808

Problem

AgentCoordTest#test_http_integration_harness_preserves_backend_test_failure_status (test/agent_coordination_cli_test.rb:1176) fails with Errno::EADDRINUSE ... 127.0.0.1 port 8787 whenever any other process holds that port. The harness's stub npx hard-codes 127.0.0.1:8787 (test/agent_coordination_cli_test.rb:73-78, introduced in PR #24) with no free-port allocation, so concurrent lanes on one machine (a second test run, a real wrangler dev, another agent worktree) make the suite flake.

Evidence (QA lane, batch ac-datafix-20260715-2339, 2026-07-17)

  • Failed once during a full-suite run while another lane was active: Expected: 42 Actual: 1, "wrangler dev exited before becoming healthy", EADDRINUSE on 8787; clean rerun passed (12 suites, 426 runs, 0 failures).
  • Deterministic two-way repro: hold the port with a dummy TCPServer → identical failure signature; release it → passes.
ruby -e 'require "socket"; TCPServer.new("127.0.0.1",8787); sleep 60' &
bundle exec ruby -Itest test/agent_coordination_cli_test.rb -n test_http_integration_harness_preserves_backend_test_failure_status

Direction

Allocate an ephemeral port in the harness stub (bind port 0, read the assigned port, pass it through to the stub server and health check) so parallel suite runs and concurrent wrangler processes cannot collide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions