Declined
Last Updated: 29 May 2023 11:12 by ADMIN
Stewart
Created on: 15 May 2023 14:29
Category: FileSelect
Type: Bug Report
0
FileSelectFileInfo Stream.CopyToAsync to MemorySteam, edge case

Hi,

We have found a strange issue that I have created a REPL to reproduce: https://blazorrepl.telerik.com/cnupFJbS23F6HHJ006

1. Select a .doc file

2. Select a second file

3. Click the "Copy Memory Stream" Button

the method stops at CopyToAsync for the .doc file

It seems to work fine if the files are selected together or if different file types are used

I have been testing with the attached .doc and a blank .txt file

Attached Files:
3 comments
ADMIN
Yanislav
Posted on: 29 May 2023 11:12

Hello,

After reviewing the details, we have decided to update the bug report status to "Declined." I've tried to cast the `FileInfoStream` to `System.IO.Stream` and the problem is still reproducible, therefore it seems the issue is related to the `Stream` class API and the `CopyToAsync` method.

Regards,
Yanislav
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Stewart
Posted on: 22 May 2023 13:55

Hi Yanislav,

Thank you for getting back to me

I will implement the suggested fix

 

ADMIN
Yanislav
Posted on: 22 May 2023 13:06

Hello Stewart,

Thank you for providing an example! It was really helpful.

I successfully replicated the issue you mentioned. It appears that when calling the await `Stream.CopyToAsync` method, the program hangs. While I'm not an expert in streams, it seems like the problem could be related to a deadlock. It's worth noting that the `CopyToAsync` method is inherited from the `System.IO.Stream` class, so it is not a method that we've implemented ourselves. Therefore, to gain further insights, I conducted research and found that similar issues have been reported in various scenarios not related to Telerik UI.

Based on my findings, one potential solution that seems to work is to use the `Task.Run()` method. By executing the `CopyToAsync` method on a separate thread, we can avoid the deadlock issue, and the program runs without hanging.

Task.Run(() =>
{
    file.Stream.CopyToAsync(ms);
}).Wait();

Here is a modified example that demonstrates this approach: https://blazorrepl.telerik.com/GHEpGcvY091FijBg32

I hope this explanation clarifies the situation and offers a viable solution to the problem you encountered. In the meantime, I'll discuss the issue further with our development team to confirm if the issue is related to the FileInfoStream, then update the thread status.

Regards,
Yanislav
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!