socket icon indicating copy to clipboard operation
socket copied to clipboard

[next] Issue with Blob URLs for Worker

Open chrisfarms opened this issue 1 year ago • 0 comments

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

chrisfarms avatar Jul 04 '24 05:07 chrisfarms