You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to begin with a question: Are null messages actually allowed in this library?
I'm not sure, because I have multiple sources, and they all contradict each other:
The signature of the IContext.Message indicates that messages can be null:
But if you try to send a null message from an actor to another, then the message apparently will be skipped. I digged a bit in sources, and found that I guess is the reason:
So null messages are successfully put in the mailbox, but are discarded during processing.
But honestly, it seems more like a coincidence rather than a desired behavior. nulls are skipped here because _userMailbox.Pop() returned null, but it will do this, as we see by the code below, in two cases:
if the mailbox is empty (and this is an intended behavior);
if the message happened to be null by its value.
So maybe this behavior is actually a bug.
But, in spite of the 2. point, the null messages won't be skipped if they are sent to a Future, because they are not actors, therefore they don't have mailboxes with this strange behavior.
There is a PR prevent null messages #1145 that explicitly says that null messages should not be allowed, but it is in a different context of remote actors, so I am not sure if it is appliable here.
Anyway, this issue is about another problem. In F#, None (option) and () (unit) values are represented as null in runtime. So, if null messages are actually not allowed, then these very general and frequently used types become unusable, efficiently making the whole F# unusable for using this library.
I would like to begin with a question: Are
nullmessages actually allowed in this library?I'm not sure, because I have multiple sources, and they all contradict each other:
The signature of the
IContext.Messageindicates that messages can be null:protoactor-dotnet/src/Proto.Actor/Context/ISenderContext.cs
Line 25 in e453945
But if you try to send a
nullmessage from an actor to another, then the message apparently will be skipped. I digged a bit in sources, and found that I guess is the reason:protoactor-dotnet/src/Proto.Actor/Mailbox/DefaultMailbox.cs
Lines 220 to 222 in e453945
So
nullmessages are successfully put in the mailbox, but are discarded during processing.But honestly, it seems more like a coincidence rather than a desired behavior. nulls are skipped here because
_userMailbox.Pop()returned null, but it will do this, as we see by the code below, in two cases:protoactor-dotnet/src/Proto.Actor/Mailbox/UnboundedMailboxQueue.cs
Line 19 in e453945
nullby its value.So maybe this behavior is actually a bug.
But, in spite of the 2. point, the
nullmessages won't be skipped if they are sent to a Future, because they are not actors, therefore they don't have mailboxes with this strange behavior.There is a PR prevent null messages #1145 that explicitly says that
nullmessages should not be allowed, but it is in a different context of remote actors, so I am not sure if it is appliable here.Anyway, this issue is about another problem. In F#,
None(option) and()(unit) values are represented asnullin runtime. So, ifnullmessages are actually not allowed, then these very general and frequently used types become unusable, efficiently making the whole F# unusable for using this library.