Skip to content

Commit

Permalink
Add working for extism cli bug
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Lewis <[email protected]>
  • Loading branch information
gmlewis committed Jul 9, 2024
1 parent 5a8ea5c commit 18f6a61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion moon.mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "extism/moonbit-pdk",
"version": "0.17.0",
"version": "0.18.0",
"deps": {
"gmlewis/json": "0.11.0"
},
Expand Down
8 changes: 7 additions & 1 deletion pdk/host/host.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ pub fn output_json_value(j : @json.JsonValue) -> Unit {
fn set_error_bytes(b : Bytes) -> Unit {
let mem = output_bytes_to_memory(b)
@extism.error_set(mem.offset)
mem.free()
// If the following line is uncommented, the Extism CLI fails with this example:
// $ extism call target/wasm/release/build/main/main.wasm greet --input "Benjamin" --wasi
// Error: Encountered an unknown error in call to Extism plugin function greet
// However, with the line commented out, the Extism CLI responds correctly:
// $ extism call target/wasm/release/build/main/main.wasm greet --input "Benjamin" --wasi
// Error: Sorry, we don't greet Benjamins!
// mem.free()
}

/// `set_error` converts a MoonBit String (UTF-16) to an Extism string (UTF-8)
Expand Down

0 comments on commit 18f6a61

Please sign in to comment.