Skip to content

Preserve order in mixed stream receivers #298

In review

Description

@llucax

What happened?

GrpcStreamBroadcaster.new_receiver(include_events=True) merges two independently buffered receivers, one for data and one for events. The broadcaster sends events and data in order, but the merged receiver doesn't preserve the order between the two buffers.

I reproduced data arriving before StreamStarted, and StreamFatalError arriving ahead of the last two queued data items. The documented example stops reading when it receives StreamFatalError, so a caller following it can miss data the broadcaster had already sent.

What did you expect instead?

A mixed receiver should yield events and data in the order the broadcaster sent them, except for messages dropped if the receiver's buffer fills. A terminal event should not jump ahead of data that's already queued. Data-only receivers should be unaffected.

Affected version(s)

Confirmed in the v0.11.5 code with frequenz-channels 2.0.1.

Affected part(s)

Code (part:code)

Extra information

One option is a single FIFO for mixed receivers. That would also make maxsize a shared capacity for events and data, rather than a separate limit for each, so the buffering behavior should be decided and documented. Add a test that queues several data items and a terminal event before reading, then asserts their relative order. This overlaps with the receiver code in #281, which still merges the two buffers.

Activity

  1. added this to the Untriaged milestone on Nov 30, 2026
  2. added
    priority:❓
    type:bug
    part:code
    on Nov 30, 2026
  3. modified the milestones: Untriaged, v0.11.6 on Nov 30, 2026
  4. self-assigned this
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

part:codepriority:❓type:bug

Type

No type

Fields

Priority

None yet

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions