Blazor WebAssembly & Azure.Storage.Blobs upload freezing/hanging
See original GitHub issueDescribe the bug
When using the Azure.Storage.Blobs package from Blazor wasm to upload files to blob storage the application is freezing, even though the upload succeeds to the blob storage endpoint (files can be then be retrieved to ensure they’ve been written correctly).
There is a difference in behaviour if the result of the UploadAsync is awaited or not (see code extract below). If it’s awaited, the first file in the files collection will be successfully written to blob storage - but then the UI will freeze. If the result is not awaited all the files in the collection will be successfully written to blob storage, then the UI will freeze.
To Reproduce
What steps can we follow to reproduce the issue?
Using Azure.Storage.Blobs nuget package (12.2.0)
BlobServiceClient service = new BlobServiceClient(<blob_connection_string>);
BlobContainerClient container = service.GetBlobContainerClient(<blob_container>);
foreach (var file in _files)
{
var blobClient = container.GetBlobClient(file.Name);
// get file stream (ms)...
// This will successfully upload the file to blob storage, but then hang on the first file
await blobClient.UploadAsync(ms, overwrite: true);
// If you don't await the result like the below- all files will will successfully upload to blob storage, then it will hang
blobClient.UploadAsync(ms, overwrite: true, System.Threading.CancellationToken.None);
}
Full sample here: https://github.com/daltskin/BlazorFile2Azure/blob/blobsdk/Client/Pages/UploadFileDirect.razor
WASM debugging exception:
Exception: ErrnoError
error: 44
message: “FS error”
node: undefined
name: “Azure.Storage.Blobs.dll”
Further technical details
-
ASP.NET Core version: 3.1.200-preview-014883 – Blazor v3.2.0-preview1.20073.1
-
Include the output of
dotnet --info
OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.200-preview-014883\ -
Visual Studio 2019 Preview 16.5.0 Preview 2.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
@daltskin thanks for contacting us.
I believe this is likely caused by the library internally doing .Wait() or similar. That normally doesn’t cause issues as in most cases there is a separate thread that can resume the execution and unblock the waiting thread.
In the Blazor case, there is only a single thread, so if the library blocks internally, or does something that is not totally correct with the thread management, then it is likely to block the UI completely and given that Blazor is single threaded, there’s no other thread to notify the blocked thread and resume the execution.
@danroth27 this is external, can you follow up with someone on the SDK team to get to the root of this?
Ok, filed a separate issue in the Azure SDK repo to track this: https://github.com/Azure/azure-sdk-for-net/issues/11626