BlazorMonaco icon indicating copy to clipboard operation
BlazorMonaco copied to clipboard

Update from 3.2.0 to 3.3.0 throws error

Open osre77 opened this issue 10 months ago • 8 comments

Hello,

I have a Blazor Server project using 3.2.0 and I wanted to update to 3.3.0. When I open a page with the editor on it, I get the following error:

[2025-02-03T12:09:05.748Z] Error: Microsoft.JSInterop.JSException: Could not find 'blazorMonaco.editor.setWasm' ('setWasm' was undefined).
Error: Could not find 'blazorMonaco.editor.setWasm' ('setWasm' was undefined).
    at http://localhost:5055/_framework/blazor.web.js:1:537
    at Array.forEach (<anonymous>)
    at l.findFunction (http://localhost:5055/_framework/blazor.web.js:1:505)
    at b (http://localhost:5055/_framework/blazor.web.js:1:5248)
    at http://localhost:5055/_framework/blazor.web.js:1:3041
    at new Promise (<anonymous>)
    at y.beginInvokeJSFromDotNet (http://localhost:5055/_framework/blazor.web.js:1:3004)
    at gn._invokeClientMethod (http://localhost:5055/_framework/blazor.web.js:1:62730)
    at gn._processIncomingData (http://localhost:5055/_framework/blazor.web.js:1:60119)
    at connection.onreceive (http://localhost:5055/_framework/blazor.web.js:1:53760)
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
   at BlazorMonaco.Helpers.JsRuntimeExt.SafeInvokeAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
   at BlazorMonaco.Editor.Global.Create(IJSRuntime jsRuntime, String domElementId, StandaloneEditorConstructionOptions options, EditorOverrideServices overrideServices, DotNetObjectReference`1 dotnetObjectRef)
   at BlazorMonaco.Editor.StandaloneCodeEditor.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Seems like the setWasm method is missing in js. This is a bit strange to me, since I am using a Blazor Server only project. My body section looks line in the documentation:

    <script src="_content/BlazorMonaco/jsInterop.js"></script>
    <script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"></script>
    <script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js"></script>

osre77 avatar Feb 03 '25 12:02 osre77

I have the same problem

Int32Overflow avatar Feb 04 '25 09:02 Int32Overflow

Ditto here too. Also using Blazor Server. I went through the setup steps and verified everything was configured correctly.

ctbrewer avatar Feb 05 '25 20:02 ctbrewer

See https://github.com/serdarciplak/BlazorMonaco/issues/152

jjonescz avatar Feb 07 '25 13:02 jjonescz

Didn't get a chance to try this, but having to clear the browser cache after a server update is probably not accepted by the users.

osre77 avatar Feb 07 '25 16:02 osre77

Personally I had to clear only my local cache during development (actually I just did force reload). There was no problem in production after upgrading the library.

jjonescz avatar Feb 07 '25 17:02 jjonescz

I will try on Monday.

osre77 avatar Feb 07 '25 17:02 osre77

Clearing the browser cache solved the problem for me.

Int32Overflow avatar Mar 15 '25 11:03 Int32Overflow

I finally got around to test updating to 3.3.0 again and now it works.

osre77 avatar Mar 17 '25 19:03 osre77

@osre77 So this issue is not relevant anymore and can be closed? (@serdarciplak)

denispaluca avatar Sep 01 '25 08:09 denispaluca

@denispaluca yes, the issue is solved.

osre77 avatar Sep 01 '25 15:09 osre77