microsoft / microsoft/rust-mqtt-client

Completion tokens resolve before packets are written to the transport

Open
#151 0 comments 0 reactions 1 assignee View on GitHub

@cartertinney is already working on this.

Since Sep 18, 2026.

bug
Dominant language
Rust
Stars
3
Forks
3
Avg merge
7d 8h
Merged PRs (30d)
4

Description

Description

Completion tokens for several outgoing operations currently resolve before the corresponding MQTT packet has been successfully written to the transport:

  • QoS 0 PUBLISH
  • PUBACK for an incoming QoS 1 PUBLISH
  • rejecting PUBREC for an incoming QoS 2 PUBLISH
  • PUBCOMP for an incoming QoS 2 flow

As a result, an application can observe successful completion even if the connection ends or the transport write subsequently fails before the packet is sent.

Completion tokens that wait for a packet from the peer, such as an outbound QoS 1 PUBLISH completing on PUBACK, are not affected by this timing problem.

Expected behavior

For an operation whose terminal event is sending a packet, its completion token should remain pending until the corresponding packet has been successfully written to the configured transport. If the connection ends or the write fails before that point, the token should report cancellation or failure rather than success.

A successful local transport write does not guarantee that the broker received or processed the packet.

Acceptance criteria

  • QoS 0 PUBLISH, PUBACK, rejected PUBREC, and PUBCOMP completion tokens do not resolve successfully before the corresponding packet is successfully written to the transport.
  • A failed or abandoned write does not report successful operation completion.
  • Completion timing for operations that await a peer response remains unchanged.
  • Tests cover completion before, after, and failure during the transport write.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.