`assert` blows up in v1.3.0
index.ts:
import { Test } from "@dylibso/xtp-test";
export function test() {
Test.assert("test", true, "because it's true");
return 0;
}
extism-js v1.3.0
PS D:\dylibso\xtp\cli\app> go run . plugin test https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm --with D:\x\extism\assertbug\dist\plugin.wasm
thread '<unnamed>' panicked at crates/core/src/globals.rs:486:26:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: wasm error: unreachable
wasm stack trace:
.$1260(i32,i32,i32,i32,i32)
.$1406(i32,i32)
.$1397(i32,i32,i32)
.$1422(i32)
.$68(i32,i32,i32)
.$364(i32,i32)
.$363(i32,i64,i64,i32,i32,i32) i64
.$461(i32,i64,i64,i64,i32,i32,i32) i64
.$454(i32,i64,i64,i32,i32,i32) i64
.$461(i32,i64,i64,i64,i32,i32,i32) i64
.$461(i32,i64,i64,i64,i32,i32,i32) i64
.$461(i32,i64,i64,i64,i32,i32,i32) i64
.$227(i32,i32,i32)
.$1478(i32) i32
.$1495() i32
Log file: C:\Users\muham\AppData\Local\cache\xtp\xtp-1733249505-27836.log
exit status 1
extism-js v1.2.0
PS D:\dylibso\xtp\cli\app> go run . plugin test https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm --with D:\x\extism\assertbug\dist\plugin.wasm
assert called
๐งช Testing https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm (D:\x\extism\assertbug\dist\plugin.wasm)
PASS ...... test
1/1 tests passed (completed in 42.5ยตs)
Full Repro: mhmd-azeez/assertbug
hmmm.. maybe the rquickjs runtime doesn't have whatever inner method we're wrapping in JS in the test library.
yeah, the host function in xtp plugin test never gets called, so the glue code breaks down somewhere
It's odd - I don't see anything calling any JS builtin functions that would imply the runtime is missing something:
https://github.com/dylibso/xtp-test-js/blob/main/index.ts#L220-L228
I think @bhelx had some idea what might be going wrong
Ok, the stack says the as_big_int() call fails us https://github.com/extism/js-pdk/blob/05cecf212dd5be1db8a6633dceda4c070b8b92d1/crates/core/src/globals.rs#L482-L486
Ok, the stack says the as_big_int() call fails us
Nice! how did you get the stack? even setting RUST_BACKTRACE didn't give me anything useful!
It's in your initial pasted output ๐ - sorry, not the wasm stack, just Rust's when the code panics
It's in your initial pasted output ๐ - sorry, not the wasm stack, just Rust's when the code panics
I have been staring at this error almost all day, and didn't see that crates/core/src/globals.rs:486:26: line ๐คฆ
Been there, done that! It happens ๐
I think this is because rquickjs is a little more strict about types - we have to use BigInt values for Extism pointer parameters.
It seems like the option with the least friction might be to update the js-pdk to allow BigInt or number arguments for BigInt parameters.
We could also update xtp-test-js to pass arguments as BigInt, which might be a quicker fix.