second-state / wasmedge-quickjs

A high-performance, secure, extensible, and OCI-complaint JavaScript runtime for WasmEdge.
Apache License 2.0
477 stars 59 forks source link

JsFunction bind not a function #134

Open lastmjs opened 7 months ago

lastmjs commented 7 months ago

Here's some example code:

  let bound_function = exports_js_object
      .get(&export_name)
      .to_function()
      .unwrap()
      .get("bind")
      .to_function()
      .unwrap()
      .call(&[JsValue::Int(4).into()]);

This code executes just fine as in the unwraps do not panic, but bound_function is an exception and when I dump the error it essentially says this: TypeError: not a function at bind (native).

I am trying to pass some dynamic data into a function created dynamically in Rust, and it seems the only way I can really do this is through the this_val, thus I am trying to set it. A closure will not work because of a wasmwedge-quickjs assertion that seems to panic whenever the JsFunction closure captures any of its environment.