Skip to content

Feature request: Explicit support for fire-and-forget notifications #258

@rtkktr

Description

@rtkktr

Problem
Currently, Publish awaits all notification handlers.
In some scenarios (logging, telemetry, audit events),
this introduces unnecessary latency and couples request
lifetime to non-critical background work.

Current behavior
IMediator.Publish completes only after all handlers finish,
and exceptions propagate to the caller.

Proposed solution
Provide an explicit, opt-in way to dispatch notifications
in a non-blocking, fire-and-forget manner, while keeping
the current behavior as default.

Why this fits MediatR
This keeps MediatR as an in-process mediator while enabling
clear and safe background-style notifications without
manual Task.Run or ignoring returned tasks.

Alternatives

  • _ = Publish(...) loses error visibility
  • Task.Run breaks DI scopes and ASP.NET Core guidelines
  • External queues add complexity for simple use cases

Example

mediator.PublishFireAndForget(new Event());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions