BlazorWorker: Javascript exception with Blazor Wasm .Net 5 RC 1
I am trying to use BlazorWorker in .Net 5 RC 1.
I am getting this exception in browser developer tools:
Uncaught (in promise) DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://localhost:44365/_framework/wasm/dotnet.5.0.0-rc.1.20451.14.js' failed to load.
at blob:https://localhost:44365/4eab1338-d80a-4c4e-b704-aa7277d64a7c:140:22
Here is my code that I am trying to execute on the web-worker:
// Create worker.
var worker = await workerFactory.CreateAsync();
// Create service reference. For most scenarios, it's safe (and best) to keep this
// reference around somewhere to avoid the startup cost.
var service = await worker.CreateBackgroundServiceAsync<CalculationService>();
// Reference that live outside of the current scope should not be passed into the expression.
// To circumvent this, create a scope-local variable like this, and pass the local variable.
var localRigVariable = appState.CurrentRigBeingEdited;
var localReferenceDataVariable = appState.ReferenceDataQueryResponse;
var result = await service.RunAsync(s => s.RecalculateActivities(localRigVariable, localReferenceDataVariable));
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (8 by maintainers)
I have a working version but its currently not deliverable. I need a few more hours of work to push a release, bear with me.
Mostly some notes for myself, but I’ve made a small breakthrough: I’ve found the .NET5 version of
WebAssembly.Bindings– it’s hidden insideSystem.Private.Runtime.InteropServices.JavaScript. All in theory, but what should be left is re-routing calls to this assembly instead, and then start cleaning up the dependency graph, as currently I’ve brute-forced the runtime by loading the entire contents of the blazor bootloader.no ETA yet, but I can give a status update. I’ve managed to get up .NET and running in the worker process, but not WebAssembly.Bindings as it’s not compiled against .NET5 and won’t load. So I either have to find the source code of that dll, or try to decompile-recompile the bytecode against .NET5. Another more sane alternative would be loading the blazor dlls like @marcussacana did in the past when that thing was broken. But its not as easy as back then, because it now need additional blazor javascript to work, and loading the entire blazor js probably wont fly in the worker context, not to mention it’s a huge bloat of code to load into memory just to do some interop. But for now I’m trying something down that road…