Search code examples
google-chromegoogle-chrome-extensionwebassemblywasm-bindgen

"CompileError: WebAssembly.instantiateStreaming(): Wasm code generation disallowed by embedder" In chrome v103+, not occurring in v101


I am using rust wasm to make a chrome extension and I have been running into this problem for a while. Whenever chrome (or edge) is updated past version 101, the wasm does not work. I usually solve this by manually downgrading chrome, but this is annoying and seems like a bug.


Solution

  • Working from @w0xx0m's comment, I started to adjust the content_security_policy in the extension's manifest.json file.

    Adding the code below fixed the error.

      "content_security_policy": {
        "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; default-src 'self';"
      },
    

    Make sure to take note of default-src 'self';; the extension will not load without it.