Skip to content

Mandelbrot Example errors #17

Description

@jeffslofish

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?

Activity

  1. dcodeIO commented on Sep 6, 2020

    @dcodeIO
    Member

    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
  2. jeffslofish commented on Sep 6, 2020

    @jeffslofish
    Author

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions