Skip to content

test: flaky WorkspaceCollaborationTests.Host_header_reflects_einsatzdaten_saved_in_a_clients_dialog #326

Closed

Description

@DeepDiver1975

Summary

LageBuch.Sync.Hosting.Tests.WorkspaceCollaborationTests.Host_header_reflects_einsatzdaten_saved_in_a_clients_dialog is flaky. It failed on three separate, unrelated CI runs on 2026-09-14/15:

Likely cause

The test (tests/LageBuch.Sync.Hosting.Tests/WorkspaceCollaborationTests.cs, around line 202) saves incident data from a client, which sends two commands (number, address) over a real host/client round trip, then waits for broadcasts:

// Save sends two commands (number, address); wait until both broadcasts have round-tripped.
var first = NextChange(client);
dialog.SaveCommand.Execute(null);
await first;
if (hostSession.Incident.Street is null)
{
    await NextChange(client);
}

The if (hostSession.Incident.Street is null) check is a heuristic attempt to wait for a second broadcast only when needed, but it's a race: if the first broadcast already completed both commands by the time this check runs, no second broadcast ever arrives, and the previous await NextChange(client) call hangs or times out / the assertion after it doesn't see the expected values yet — timing-dependent, so it flakes under any additional latency (CPU contention, added instrumentation, etc.).

Evidence coverage instrumentation makes it worse (but isn't the root cause)

In #323, this test failed on ubuntu-latest twice in a row with --collect:"XPlat Code Coverage" enabled on the Test step (coverlet's instrumentation overhead shifts timing), but it also failed on main and on #321 with no coverage collection involved at all — so the underlying race exists independent of coverage; coverage just appears to increase its frequency.

Suggested fix

Replace the if (hostSession.Incident.Street is null) heuristic with a wait that is unconditionally correct regardless of how the two commands get batched into broadcasts — e.g. await until both IncidentNumber and Street are observed on the host (and mirrored to the client), rather than assuming a fixed number of NextChange calls.

Context

Surfaced while implementing #301 (build/CI hygiene). Not blocking any of that work — PR #323 already decouples coverage collection from the test-correctness gate specifically because of this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions