serdarciplak / BlazorMonaco

Blazor component for Microsoft's Monaco Editor which powers Visual Studio Code.
https://serdarciplak.github.io/BlazorMonaco/
MIT License
449 stars 100 forks source link

Seeing "Attempting to reconnect to the server: 1 of 8" #109

Closed MikeWilliams-UK closed 11 months ago

MikeWilliams-UK commented 11 months ago

I have added the NuGet package BlazorMonaco 3.1.0 to my Blazor App.

When I have short json string (17,426 characters) to render/edit all is ok When I have a long json string (1,731,504 characters) to render/edit I see the above several times.

When I edit the json the OnDidChangeModelContent event is triggered. Inside my code behind the line var val = await _editor.GetValue(); is causing an exception which I see in the Visual Studio Output Window Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll

<StandaloneCodeEditor @ref="_editor"
                      Id="composite-content-editor"
                      ConstructionOptions="ConstructEditorOptions"
                      OnDidInit="EditorOnDidInit"
                      OnDidChangeModelContent="OnModelContentChanged">
</StandaloneCodeEditor>
private async Task OnModelContentChanged()
{
    Debug.WriteLine("OnModelContentChanged()");
    var val = await _editor.GetValue();
    var result = compositeContent != temp;
    IsChanged = result;
}
MikeWilliams-UK commented 11 months ago

Might be related to https://github.com/serdarciplak/BlazorMonaco/issues/106

MikeWilliams-UK commented 11 months ago

Similar belaviour is seen in Manaco Playground - Issue raised there. https://github.com/microsoft/monaco-editor/issues/4238

MikeWilliams-UK commented 11 months ago

Many thanks @da-baranov, My issue is now fixed albeit with a slight tweak required for my app as shown below

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();

builder.Services.AddSignalR(e => {
    e.MaximumReceiveMessageSize = 1024 * 1024 * 100;
});