Skip to content

Having issues with loading .wasm files in benchmarks #267

@dsafa

Description

@dsafa

I'm interested in running some code that uses wasm, but when running the benchmarks, it throws compile errors. For example:

Uncaught CompileError: WebAssembly.instantiateStreaming(): section (code 1, "Type") extends past end of the module (length 9396207, remaining bytes 1347243) @+8

Looking at the network tab and downloading the wasm binary from there, it is different than the file that is located in node_modules, so it seems like its being modified somewhere.

Here is a small test case

index.html

<script type="module">
import * as bench from '/bench.js';

const brotli = await import("brotli-wasm/index.web.js").then(m => m.default);

const textEncoder = new TextEncoder();
const input = 'some input';

const uncompressedData = textEncoder.encode(input);

bench.start();
const compressedData = brotli.compress(uncompressedData);
bench.stop();

</script>

package.json

{
  "name": "tachometer-wasm",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {},
  "author": "",
  "license": "ISC",
  "dependencies": {
    "brotli-wasm": "^3.0.1"
  }
}

Reproduction steps:

  1. run tachometer ./index.html

Expected results:

  1. No errors and benchmark should run

Actual:

  1. there is a CompileError thrown and the file brotli_wasm_bg.wasm fetched by the browser differs from the file in node_modules\brotli-wasm\pkg.web\brotli_wasm_bg.wasm

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