Bad HTTPS cert: "TypeError: Failed to execute 'compile' on 'WebAssembly': HTTP status code is not ok" in Webworker

Viewed 1399

I'm trying to run Webassembly inside a Webworker

I can load heavyLifting.wasm perfectly fine the traditional way (aka not in a webworker) but trying to load it inside a webworker runs into warnings (not errors actually). Here's how I loaded it:

// worker.js
self.importScripts('heavyLifting.js'); 

And the warning:

wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': HTTP status code is not ok

From what I gather, it finds the file - but I assume it has something to do with it not being HTTPS.

I actually haven't tried serving it through HTTPS yet (because locally serving HTTPS has become a lot more difficult for some reason). However, does anyone have any knowledge that might save me a few more hours of banging my head against the wall? Did I forget some setting or config? Why would a webworker be extra picky about what wasm it serves (because as I mentioned, I'm able to serve up my wasm fine as a regular script)

Update:

It wasn't an HTTPS error - it had to do with importScript().

worker.js
js/
  heavyLifting.js   // glue code
  heavyLifting.wasm

This was all fixed by moving worker.js down into the js folder.

I immediately ran in to the following error:

'Uncaught (in promise) TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.'

It turns out the node package http-server doesn't serve wasm properly, but the python3 http.server does.

0 Answers
Related