LostBeard / SpawnDev.BlazorJS

Full Blazor WebAssembly and Javascript Interop with multithreading via WebWorkers
https://blazorjs.spawndev.com
MIT License
78 stars 6 forks source link

TypeError: /src="(.+?)"/.exec(...) is null #12

Closed arnvanhoutte closed 9 months ago

arnvanhoutte commented 9 months ago

I'm trying to implement the webworkers in .NET 8 but I'm getting the following error in spawndev.blazorjs.webworkers.js:119:47

TypeError: /src="(.+?)"/.exec(...) is null

The specific line where this error occurs is let scriptSrc = /src="(.+?)"/.exec(scriptTagBody)[1];

The browser I'm testing this is in Firefox on Windows 11. The error occurs when running await workerService.GetWebWorker() in Blazor WASM

LostBeard commented 9 months ago

Can you please post your Blazor WASM project's index.html file? That error is related to the parsing of your index.html file and if I can examine it I can come up with a solution faster. Thank you!

LostBeard commented 9 months ago

After doing some testing I am willing to bet that you have an empty src attribute in a script tag <script src="" ... > in your index.html. I will add a catch so it doesn't crash the web worker in such an event. If that isn't the case your index.html would still help.

LostBeard commented 9 months ago

As the exception caused by an empty script tag src attribute is a bug, I have fixed and updated the repo, and the Nuget packages. Version 2.2.4 has that particular fix. Please let me know if it resolves your issue.

arnvanhoutte commented 9 months ago

The issue wasn't an empty script tag but an async script tag. It seems to be fixed in v2.2.4. Thanks for the quick help

LostBeard commented 9 months ago

Thank you for reporting the issue.