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

(node:91015) UnhandledPromiseRejectionWarning: TypeError: wasm function signature contains illegal type #26

Open
LiaoPeng opened this issue Aug 3, 2018 · 3 comments

Comments

@LiaoPeng
Copy link

LiaoPeng commented Aug 3, 2018

As the description, the module provider runtime for WebAssembly modules.
I used AssemblyScript to compile the typescript file to wasm.

export function add(x: u64, y: u64): u64 {
  return x + y;
}

Then, using the webassembly to run the module,

require("webassembly")
  .load("main.wasm")
  .then(module => {
    console.log("1 + 2 = " + module.exports.add(1, 2));
  });

I got the error below

(node:92224) UnhandledPromiseRejectionWarning: TypeError: wasm function signature contains illegal type
    at require.load.then.module (/Users/Peng/Downloads/wasm-project-yolspucnghl/out/program.js:7:45)
(node:92224) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:92224) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Is there a gap between the AssemblyScript and webassembly?
And is there a node.js module to run the webassembly modules that AseemblyScript compiled.

@xtuc
Copy link

xtuc commented Aug 3, 2018

Since JavaScript doesn't supports int64 yet, a signature with a int64 in wasm can't be exported to JS.

@theblockstalk
Copy link

also getting this issue when trying to run a .wasm file with i64 types in nodejs. anybody found a way to get this working in javascript?

@dcodeIO
Copy link
Owner

dcodeIO commented Dec 18, 2019

Support for i64's on the boundary is behind the --experimental-wasm-bigint flag in current node. Enabling that should make it work, with BigInts representing the respective i64 value in JS.

An alternative to using experimental features is to return an i32 for the low bits, and export another helper function returning the high bits of the last operation as another i32. Something like long.js's Long.fromBits can work with these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants