0

When running dotnet test on the Azure Pipeline, the pipeline fails with error:

System.Exception: Unable to read beyond the end of the stream.
   at System.IO.BinaryReader.Read7BitEncodedInt()
   at System.IO.BinaryReader.ReadString()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.LengthPrefixCommunicationChannel.NotifyDataAvailable()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TcpClientExtensions.MessageLoopAsync(TcpClient client, ICommunicationChannel channel, Action`1 errorHandler, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---.
##[error]Error: The process '/opt/hostedtoolcache/dotnet/dotnet' failed with exit code 1

The best link I could find at GitHub issue says,

_ This is expected, any testhost disconnect, is considered a crash/abort, unless vstest.console told that testhost that it is okay to exit. Your test stops the testhost, and with that, it also stops the test framework, adapter, and other logic responsible for sending back the data. So that is a crash from the point of view of vstest.console. _

But I couldn't find a solution to resolve it on my pipeline.

Any help would be appreciated

iarunpaul
  • 117
  • 2
  • 13

1 Answers1

0

Here the issue was that one of the tests were failing and that caused the failure.

Adding to the problems there was a try block which catches nothing and hence there was no trace of the test failure( which is of course weird// we should never have used try catch in tests). Obviously none of the tests "failed" and that made the debugging difficult. So the system failed with:

Test Run Aborted with error System.Exception: One or more errors occurred.

which is not very intuitive.

iarunpaul
  • 117
  • 2
  • 13
  • 1
    Any chance you're running tests that call async code? Async code on a background thread or in the garbage collector can crash the process. Similarly, if you have any unsafe code or p/invokes, that may cause process corruption which will bring down the test host. Usually these are indicative of a bigger problem. – jessehouwing Mar 10 '23 at 10:56
  • @jessehouwing I have a dotnet test that hangs (aborts after a timeout) which contains unsafe code... the stack trace is unusable and nothing gets logged. I wonder if you have any docs / resources that could help. – Rye bread Apr 25 '23 at 11:13
  • @Ryebread configure the debugger/watson to automatically create a process dump and tear your hair out for 18 hours looking at the unmanaged debugger. – jessehouwing Apr 25 '23 at 13:15