Skip to content

Fixes flaky remove_listener subscriber test - #35

Merged
johnnyt merged 1 commit into
mainfrom
sui-hmm-subscriber-flake
Aug 22, 2026
Merged

Fixes flaky remove_listener subscriber test#35
johnnyt merged 1 commit into
mainfrom
sui-hmm-subscriber-flake

Conversation

@johnnyt

@johnnyt johnnyt commented Aug 22, 2026

Copy link
Copy Markdown
Member

Why

test/statifier_ui/trace/subscriber_test.exs - "remove_listener/2 stops
delivery to that pid" - failed intermittently: on 2026-08-22 it broke one
full-gate run on a branch that never touched the file, passed on immediate
rerun, and stayed green across three consecutive later gates. A timing race,
not branch-related (sui-hmm).

What

Test-only change. The test called add_listener/2 (a call from the test
process) immediately after start_early!, racing the initialize burst's
{:statifier, ...} messages (sends from the session process) into the
subscriber's mailbox - cross-sender delivery order is not guaranteed, so the
listener occasionally caught burst messages that later tripped
refute_receive.

The test now registers the listener at start_link time via
start_early!(..., listeners: [self()]), so it deterministically sees the
whole burst; it asserts seq 0..5 arrive (delivery was live), removes the
listener with the synchronous call before driving the event, and ends on
refute_received - the subscriber's final stats reply is ordered after any
fan-out send, so no sleep or timeout is needed.

Notes

  • No Subscriber semantic change: fan-out and add/remove_listener behavior are
    untouched, so the just-merged inspector assembly's attach/catch-up usage is
    unaffected. Full suite green on the rebased tree (3b43827), including the
    new catch-up tests.
  • Evidence: 100 runs of the test file under 8 busy-loop processes of CPU
    load, before vs after - before: 7/100 failures, all this test; after:
    0/100. (One further before-run iteration failed differently because the
    checkout was pulled mid-run - a torn-state artifact, not a flake.)
  • Gate: full gate green - 427/427 tests, 92.3% coverage, Dialyzer clean;
    Gettext and Sobelow are declared not applicable in this repo.

Closes sui-hmm.

The test called add_listener/2 right after start_early!, racing the
initialize burst's messages into the subscriber's mailbox - sends from
different processes have no cross-sender ordering guarantee, so the
listener occasionally caught burst messages that later tripped
refute_receive (7 of 100 runs failed under CPU load; 0 of 100 after).

The listener is now registered at start_link time, so it
deterministically sees the whole burst. The test asserts seq 0..5
arrive, removes the listener with the synchronous call, drives the
event, and ends on refute_received - the subscriber's final stats
reply is ordered after any fan-out send, so no timeout is needed.

Refs: sui-hmm
@johnnyt
johnnyt merged commit 876898b into main Aug 22, 2026
1 check passed
@johnnyt
johnnyt deleted the sui-hmm-subscriber-flake branch August 22, 2026 20:12
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