Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Failure to serialize Array on Async interop #15754

Closed
galvesribeiro opened this issue Jul 26, 2018 · 2 comments
Closed

Failure to serialize Array on Async interop #15754

galvesribeiro opened this issue Jul 26, 2018 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@galvesribeiro
Copy link
Member

Hello folks,

While updating the Storage extension to 0.5.0, I've found a potential bug with the async interop.

If I send an an array, lets say WeatherForecast[] from C# -> JS, it works just fine. When JS is sending back an array as return of of a method, the runtime just stops. Nothing happen. No errors, nothing.

To reproduce:

On a TS/JS:

  public GetItem(myArray: any): any {
    return myArray
  };

On C#:
That works:

        public WeatherForecast[] GetItem(WeatherForecast[] myArray)
        {
            return ((IJSInProcessRuntime)JSRuntime.Current).Invoke<WeatherForecast[]>("GetItem", myArray);
        }

That doesn't works:

        public Task<WeatherForecast[]> GetItem(WeatherForecast[] myArray)
        {
            return JSRuntime.Current.InvokeAsync<WeatherForecast[]>("GetItem", myArray);
        }

In other words... If we call it sync it works, but if we call async, it fail.

My first thought was something wrong with the serialization, but that works in the sync mode, so we discarded it.

We are suspecting endInvokeDotNetFromJS isn't being caller or is failing somehow.

I would appreciate any help on that.

Thanks

@galvesribeiro
Copy link
Member Author

As this is a blocker, I'm changing the code to internally send a string with the array JSON-serialized for now while we don't have a solution for it.

@galvesribeiro
Copy link
Member Author

Thanks for the quick fix! 👍

Looking forward for 0.5.1

@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/blazor Oct 27, 2019
@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Oct 27, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

2 participants