Closed paulhickman-a365 closed 6 years ago
Are you calling into this code from a synchronous context? If yes, change your unit test to itself be async
. If no, call ConfigureAwait(false)
in the unit test. Please let us know if this resolves your hangs.
Separately, the legacy ASP.NET code does not call ConfigureAwait(...)
anywhere and could break existing applications if that changes -- especially (as is possible in PushStreamContent
) when await
ing user code.
Turned out to be a red herring - the unit test wasn't closing the stream which caused SerializeToStreamAsync to not return.
In PushStreamContent.cs the method
SerializeToStreamAsync
performs two awaits but does not useConfigureAwait(false)
which means it tries to re-acquire the calling the thread context.This is causing a threading deadlock in my unit tests. Is this intentional behaviour, or an oversight?