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
In MultipartFormDataRequestContent.WriteTo function, it will call _multipartContent.CopyToAsync(stream).EnsureCompleted(); for .NET which is not NET6, such as Net standard2.0. But in EnsureCompleted function, there is an assert to check if the task is completed (see following). So when we run sync method with a DEBUG version SDK, it will fail.
Possible solution:
We will not use TaskExtensions.EnsureCompleted function for azure SDK, and directly call _multipartContent.CopyToAsync(stream).GetAwaiter().GetResult(); as what we do for non-azure SDK.
Per offline discussion, it is by-design that we are doing sync-over-async in the sync/netstandard2.0 case, and cannot be avoided when using the BCL MultipartFormDataContent type. Given this, the recommendation is:
Add a net6.0 target to libraries that send multipart/form-data requests. This would look like the following change to the .csproj file:
Change the internally emitted class to call GetAwaiter().GetResult() instead of EnsureCompleted(), (e.g. here). This would look like:
The Core team has work in progress to add the net6.0 TFM as a RequiredTargetFrameworks for all client libraries. However, this requires further due-diligence and investigation, so it is important that this change not yet be added to all client library .csproj files -- only those using multipart/form-data.
Please note that if we do only item 2 without also doing item 1, clients will do sync-over-async even on net6.0 platforms and this is highly undesirable. Please only do the two together. This relates to the guidance that we should not include the emitted MultipartFormDataRequestContent.cs in clients that do not use it.
Also, because we will be doing sync-over-async in these cases, there is a chance that these tests may fail nondeterministically. If they become flaky, we should find a way to [Ignore] them, but only for the MPFD/netstandard2.0/sync cases -- it would be preferable to continue testing the net6.0+/sync cases in case we identify further issues that need to be investigated and corrected.
When build SDK in Debug version, and run sync API of MFD operation, exception throw
Task is not completed
inEnsureCompleted
The text was updated successfully, but these errors were encountered: