The ReceiveMessage_should_handle_out_of_order_replies test sometimes fails due to what looks like a race condition.
The output of the test when it fails is:
MongoDB.Driver.Core.Connections.BinaryConnectionTests.ReceiveMessage_should_handle_out_of_order_replies(async1: False, async2: False) [FAIL] MongoDB.Driver.MongoConnectionException : An exception occurred while receiving a message from the server. ---- System.IO.EndOfStreamException : Attempted to read past the end of the stream. Stack Trace: D:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Driver.Core\Core\Connections\BinaryConnection.cs(329,0): at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer() D:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Driver.Core\Core\Connections\BinaryConnection.cs(365,0): at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(Int32 responseTo, CancellationToken cancellationToken) D:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Driver.Core\Core\Connections\BinaryConnection.cs(454,0): at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessage(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken) D:\jenkins\workspace\mongo-csharp-driver-build\tests\MongoDB.Driver.Core.Tests\Core\Connections\BinaryConnectionTests.cs(395,0): at MongoDB.Driver.Core.Connections.BinaryConnectionTests.<>c__DisplayClass17_0.<ReceiveMessage_should_handle_out_of_order_replies>b__0() at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) D:\jenkins\workspace\mongo-csharp-driver-build\tests\MongoDB.Driver.Core.Tests\Core\Connections\BinaryConnectionTests.cs(415,0): at MongoDB.Driver.Core.Connections.BinaryConnectionTests.ReceiveMessage_should_handle_out_of_order_replies(Boolean async1, Boolean async2) ----- Inner Stack Trace ----- D:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Driver.Core\Core\Misc\StreamExtensionMethods.cs(39,0): at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytes(Stream stream, Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) D:\jenkins\workspace\mongo-csharp-driver-build\src\MongoDB.Driver.Core\Core\Connections\BinaryConnection.cs(315,0): at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer()