website icon indicating copy to clipboard operation
website copied to clipboard

Mandelbrot Example errors

Open jeffslofish opened this issue 5 years ago • 2 comments

I am trying to run the Mandelbrot Example locally, and I ran into this error when serving the content with http-server:

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

I eventually (I believe) found a way to serve the wasm with the correct MIME type using a php server. The documentation I found is here: https://www.php.net/manual/en/features.commandline.webserver.php#example-424. Following this I created a file called router.php with the following contents:

<?php
// router.php
$path = pathinfo($_SERVER["SCRIPT_FILENAME"]);
if ($path["extension"] == "wasm") {
    header("Content-Type: application/wasm");
    readfile($_SERVER["SCRIPT_FILENAME"]);
}
else {
    return FALSE;
}
?>

then I ran php -S localhost:8000 router.php. At this point I ran into a new error: Uncaught (in promise) TypeError: Cannot read property 'update' of undefined in which the "exports" variable coming from the line }).then(({ exports }) => { is undefined.

Any ideas what is going wrong here?

jeffslofish avatar Sep 06 '20 08:09 jeffslofish

Does this also happen when following the very last steps in the example docs using the http-server node module?

npm install --save-dev http-server
http-server . -o -c-1

dcodeIO avatar Sep 06 '20 16:09 dcodeIO

Yes, i get the following:

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

Apparently there is a bug in http-server in that it serves a charset with application/wasm

jeffslofish avatar Sep 06 '20 17:09 jeffslofish