Cannot get WASM to work?

I wanted something more efficient for verifying password hashes so i tried using bcrypt wasm and argon2 wasm, but both give this error:

Uncaught TypeError: WebAssembly Instantiation: Import #0 module="env" error: module is not an object or function

I’ve of course added them to wasm resources and verified with another wasm that wasm actually works, but neither of these work:

Did you get it working on different platform or with another wasm in Cloudflare? I have the same issue.

Sorry to say, but only hashing algos that require little CPU-time work on Cloudflare workers due to the limits on it.

In other words, bcrypt and argo2 don’t work.

I too have this issue and I don’t understand why. My wasm file just emits 9kb u8[] so nothing CPU based and yet I have this same error, unsure how to proceed.

Maybe there’s a loop in the wasm? It might give the same result as cpu running out.

1 Like

nvm I solved it, I’m using AssemblyScript and it requries a boilerplate “env” function on the imports I didn’t realise this and now it works.

const imports = {
    env: {
      abort(_msg, _file, line, column) {
        console.error("abort called at index.ts:" + line + ":" + column);
      }
    }
  };

const instance = new WebAssembly.Instance(/* WASM NAME */, imports).exports;
instance.doSomething();
1 Like

Thanks for sharing the solution to the problem :slight_smile:

1 Like