Open stmax82 opened 5 years ago
Looking at these
Test2 - agreed this is a bug.
Tests 3, 4, 5, 6, 7, 8 - this is an open question - if the async for the mailbox exits, then should outstanding un-replied requests be cancelled, or fail, or simply never answer? Currently they simply never answer, but I can see the logic in throwing Disposed or Cancelled
Thanks for the excellent repro
I guess the easiest way to handle these cases would be to throw ObjectDisposed for all un-replied (and newly incoming) requests after the async of the mailbox has exited - and no matter how it has exited (normally, exception, cancelled, disposed). So if it's not running anymore, you get ObjectDisposed.. easy to handle.
(I doubt it would help the caller if he had to handle 3 or 4 different exceptions depending on how the async of the mailbox has exited?)
Thanks for looking into these cases!
Below are 9 unit tests, 2 green / 7 red.
Situation
The red tests show cases where the MailboxProcessor.PostAnd(Async)Reply calls get stuck for eternity due to different reasons. I think things should never get stuck forever.
This might be related to case #4448, which was fixed a while ago, but there seem to be more cases with similar effects.
Workaround
Minimally set a cancellation token, e.g.
cancellationToken=CancellationToken.None
on the mailbox processor (which is intended only to govern the asynchronous computation running in the mailbox, and not the request-reply to fetch information). This changes the behaviour ofMailboxProcessor.PostAndAsyncReply
and friends to respect cancellationRepro
Tested with FSharp.Core 4.6.2.