Skip to content

Misleading error text when IllegalActorStateException is raised on attemp to stash a lifecycle message #7398

@object

Description

@object

Version Information
Version 1.5.31

Describe the bug
If an actor tries to stash a lifecycle message (e.g. PreStart), the IllegalActorStateException is raised with the text "Can't stash the same message more than once". The text is supposed to include the actual message, but in case of PreStart current message is null, so no message information is included in the text. This is confusing because there is no attempt to stash a message twice, there is an attempt to stash a message that can't be stashed.

Expected behavior
Either InvalidOperationException should be raised, or the text for IllegalActorStateException should state that such message can't be stashed.

Actual behavior
IllegalActorStateException is raised with the text "Can't stash the same message more than once".

Additional context
In case a lifecycle message is being stashed, the currMessage is null, and both _currentEnvelopeId and _actorCell.CurrentEnvelopeId are zero (their equality triggers the exception). So there should be a check for nullable currMessage that should trigger either better exception text or InvalidOperationException.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDeveloper experience issues - papercuts, footguns, and other non-bug problems.akka-actorlogging

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions