Has JsRuntime.InvokeAsync a return value size limitation?

2.7k Views Asked by At

When I try to call a JavaScript function from a Blazor function the connection between my serverside Blazor App and the server breaks, when the function returns a string which is longer than 32,721 charakters. I'

In my Razor page I execute:

var data = await JsRuntime.InvokeAsync<string>("myfunction");

The JavaScript function myfunction looks like this:

function myfunction() {
  return 'x'.repeat(32721);
}

This works, but when I use 32722 as argument the connection breaks and I don't know why and how to work around this.

Splitting the string in 1000 byte long chungs and returning a string[] didn't work as well.

I need to return around 200.000 bytes. Is there any limitation?

Watching the messages of the websocket I can see the message with 103kB, then "JS.RenderBatch", "OnRenderCompleted" and finally "Connection closed with an error" but I can not find any error message in any console or log.

1

There are 1 best solutions below

0
On BEST ANSWER

It's the SignalR message size limit. See this GitHub issue. There's also this from the MS docs on chunking a response to work around the message size limitation.