mirror of
https://github.com/ruvnet/RuView
synced 2026-07-20 17:03:24 +00:00
967cede74d
Third cause of the state_messages_published_on_snapshot_broadcast failure (after timing fix in5ed8e3451and client_id fix in2aeed32a7): the subscriber's eventloop was NEVER polled between `client.subscribe(...).await` and `collect_published(eventloop, ...)`, so the SUBSCRIBE packet was only queued in rumqttc's outbound channel — it didn't reach the broker until collect_published began polling. By that time the publisher had already emitted all 6 state messages. The retained ones (binary_sensor presence with retain=true) should have been redelivered on the late subscribe, but only the LAST one would land — yet CI was reporting `got []` (zero messages). Theory: the broker may not redeliver retained messages reliably when the subscribe arrives during the publisher's burst, OR the test's collect_published timing budget runs out before redelivery completes. Fix: drain the subscriber's eventloop inside `subscribe_client` until we see the SubAck for our subscribe. That guarantees the subscription is active at the broker BEFORE the function returns, so non-retained publishes from the publisher's send loop arrive normally. Also made the subscriber client_id include a per-call nanosecond suffix so subscribers in back-to-back tests can't collide on a shared ID (paranoia, complementary to the publisher-side fix from2aeed32a7). Refs PR #778, issue #776. Co-Authored-By: claude-flow <ruv@ruv.net>