Skip to content

Flaky: FakeOtlpCollector HttpListener disposed / address in use in OtlpSubprocessExporterTests and FakeOtlpCollectorTests #672

Description

@mforce

Seen twice on 2026-09-02 while shipping #562 (PR #671), both in the FakeOtlpCollector test scaffolding, neither reproducible on a clean re-run, and neither touching files the PR changed:

  1. Locally (implementer's first foreground full-suite run, Release): FakeOtlpCollectorTests.Predicate_wait_throws_a_terminal_error_completed_at_the_timeout_catch_boundary — System.Net.HttpListenerException: Address already in use. Immediate re-run green (1654/1654).
  2. CI (run 33704636108, job Build and test, head 667a4242): OtlpSubprocessExporterTests.Production_plaintext_loopback_endpoint_with_acknowledgement_boots — System.ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net.HttpListener' at FakeOtlpCollector..ctor() (tests/Cluckwork.Api.IntegrationTests/Infrastructure/FakeOtlpCollector.cs:35, HttpListener.get_Prefixes). Re-run: see the PR's checks.

For context, main's own CI run on the same base commit (80b53f4b, run 33695280424) failed on a third timing-bound test, DurableJobWorkerLeaderGateTests.Follower_NeverPolls_ButStampsHeartbeat (Assert.NotNull() Failure on the heartbeat), so the runner class is already marginal for timing-sensitive integration tests.

What to look at

  • FakeOtlpCollector.cs:35 reads Prefixes on a listener that has been disposed — most likely the port-probe/retry loop disposing a listener it then reuses, or a static/shared listener across parallel test classes.
  • Port selection: two tests binding loopback ports concurrently (Address already in use) suggests the collector picks a port without holding it, or two fixtures share a port range.

Verify

A fix must come with a loop that runs the two named tests N times in parallel with the rest of the integration collection and stays green; a single green run proves nothing about a flake.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:apiAPI/endpoint layer

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions