socketsupply / socket

A cross-platform runtime for Web developers to build desktop & mobile apps for any OS using any frontend library.
https://socketsupply.co/guides
Other
1.6k stars 75 forks source link

[next] Issue with Blob URLs for Worker #985

Open chrisfarms opened 2 months ago

chrisfarms commented 2 months ago

What did you expect to see and what you saw instead?

I expect to be able to create blob URLs for Worker source without providing a mime type for blob.

For example this code works in browsers:

 new Worker(URL.createObjectURL(new Blob([`let x = 1;`])))

but the same code will cause the following errors in Socket and the worker will not work:

Unhandled Promise Rejection: TypeError: Invalid URL: .  (container.js:315)
TypeError: '' is not a valid JavaScript MIME type.

It doesn't fail in a nice way either ... it looks like it has setup a worker, but it is non functional.

Little bit of investigating

It looks like the issue is because the RuntimeWorker, that wraps the real Worker, passes the blob URL to import() ... and this is the problem, since import() requires a js mime type.

There are many mimeless worker blobs out in the wild, I'm currently using Three.js and almost all of the Loader code that spins up workers requires them.

What OS are you using (uname -a, or Windows version)?

Darwin macbook 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64

What version Socket Runtime are you using?

next