cancel pending delayed will on reconnect and bound it by session expiry - #170
Merged
Merged
Conversation
This was referenced Sep 25, 2026
fabracht
force-pushed
the
will-delay-cancel
branch
from
September 27, 2026 19:32
ec4b24f to
0503dbc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #154.
Problem
With a Will Delay Interval, the broker slept in a detached task and then published the Will unconditionally. So:
[MQTT-3.1.3-9]and[MQTT-3.1.2-8].[MQTT-3.1.2-10]).[MQTT-3.1.3-9]passed vacuously, because it stopped watching before the delay elapsed.Fix
MessageRoutertracks pending delayed Wills per ClientID. Any new connection for that ClientID cancels the pending Will inregister_client: resume, Clean Start, or takeover. Claim and cancel happen under the same lock, so exactly one of them wins.Tests
crates/mqtt5/tests/will_delay.rs: 11 tests. The resume, Clean Start, expiry-0, expiry-shorter, reconnect-then-drop and takeover cases fail on the previous code.crates/mqtt5-wasm/tests/broker_will_delay.rsplus wasm unit tests, driving the real wasm broker.[MQTT-3.1.3-9]test now waits past the delay. A new positive control checks that the Will is published when no reconnect happens.mqttv5 brokerbinary with file storage and SIGKILLed CLI clients. The fixed build behaved correctly in all five scenarios. The released v0.41.0 binary published spurious Wills after resume and after a Clean Start reconnect, and missed the session-end deadline.Versions: mqtt5 0.41.1, mqtt5-wasm 2.0.1.