Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

application/wasm support in Chrome #1598

Closed
2 of 10 tasks

Comments

@Zambiorix
Copy link

Issue details

I am using browser-sync to support my development of WebAssembly modules.
This works in Safari and FireFox, but in Chrome I get the following error:

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

It seems that browser-sync (or the underlying serve-static) does not recognise .wasm files and set the corresponding (application/wasm) Content-Type header.

I tried to define a new MIME type (see below), but that does not seem to work.

How can I solve this?

Steps to reproduce/test case

Please provide necessary steps for reproduction of this issue, or better the
reduced test case (without any external dependencies)
.

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ 2.24.7 ]
  • Node [ v6.11.1 ]
  • Npm [ 6.4.0 ]

Affected platforms

  • linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • CLI

If CLI, please paste the entire command below

browser-sync start --config config/bs-config.js

In my config file, I define a new callback where I update the serve-static mime types.
The output log shows that application/wasm is indeed added, but still I do not get the correct mime-type in my browser...

"callbacks": {
    ready: function(err, bs) {

        bs.utils.serveStatic.mime.define({ 'application/wasm': ['wasm'] });

        console.log(bs.utils.serveStatic.mime);
    }
},

for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

{Browsersync init code here}

@Zambiorix
Copy link
Author

Actually, I just noticed that I do not get a Content-Type at all ...
Is this a bug?

@Zambiorix
Copy link
Author

Zambiorix commented Aug 29, 2018

OK, as it usually happens, one finds the solution 2 minutes after posting the question.

I can confirm that the (config options) code below works:

"callbacks": {
    ready: function(err, bs) {

        bs.utils.serveStatic.mime.define({ 'application/wasm': ['wasm'] });

        console.log(bs.utils.serveStatic.mime);
    }
},

... I just had to clean my browser cache, the stored version didn't have the mime yet ... sigh

@Zambiorix Zambiorix changed the title application/wasm support application/wasm support in Chrome Aug 29, 2018
@Zambiorix Zambiorix reopened this Aug 29, 2018
@Zambiorix
Copy link
Author

Maybe you could add this example on your website on how to add custom mime-types

@shakyShane
Copy link
Contributor

@Zambiorix since this is so important, I've decided to add this fix into the core for now. browser-sync@2.26.3

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