Skip to content

[Bug] BoundedMailbox drop-head overflow is a no-op while the mailbox is suspended #407

Description

@pathosDev

Rationale

BoundedMailbox implements drop-head overflow via super.dequeueUser() (src/mailbox/BoundedMailbox.ts:43-48). But Mailbox.dequeueUser() returns undefined without removing anything while the mailbox is suspended (src/internal/Mailbox.ts:49-52) — e.g. during a supervision restart or while a stash gate holds the actor. The overflow branch then still enqueues the new envelope:

  • the "bounded" queue grows past capacity for as long as the mailbox stays suspended under a flooding producer, and
  • droppedCount / onDrop (and any metric built on them) report drops that never happened.

Scope

  • Drop from the underlying buffer regardless of suspension (e.g. a protected removeOldest() on Mailbox that bypasses the suspended gate) — drop-new and reject semantics stay unchanged.
  • Test: enqueue past capacity while suspended → size === capacity and droppedCount matches actual removals; resume → normal delivery order.

Note (current state, v0.11): overflow values are 'drop-head' | 'drop-new' | 'reject' (default 'reject'), and BoundedMailboxOptions + BoundedMailboxOptionsValidator already exist — this issue only touches the suspended-drop logic.

Documentation

  • CHANGELOG Fixed entry.
  • Mailbox docs note (EN + DE) on overflow semantics during suspension.

Acceptance

  • Capacity invariant holds under suspend/resume; drop metric matches reality; existing mailbox tests green.

Relates

#310 (bounded default mailbox). Improvement program M1/S4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingseverity: highSignificant impact, exploitable in standard threat model

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions