Support WASM Api by mssalemi · Pull Request #460 · Shopify/function-runner
Wasm API Support for function-runner
Closes: https://github.com/shop/issues-shopifyvm/issues/32
Function-runner now detects when a module is using the Wasm API by checking if it imports modules with names starting with shopify_function_v.
When a Wasm API function is detected:
- The input is automatically transcoded from JSON to MessagePack
- The Wasm API provider (shopify_function_v0.0.1.wasm) is loaded
- The output is automatically transcoded from MessagePack back to JSON
For output handling:
- Locates the actual MessagePack data in the output stream
- Extracts only the relevant MessagePack portion for processing
- Properly decodes it to JSON for the function result
🎩 Tophat
WASM API
cargo run -- -f tests/fixtures/build/echo.trampolined.wasm -i tests/fixtures/input/wasm_api_function_input.json
JAVY_V2
cargo run -- -f tests/fixtures/build/js_function_javy_plugin_v2.wasm -i tests/fixtures/input/js_function_input.json -e run
Testing
- Added unit tests for Wasm API function execution
- Added integration tests for running Wasm API functions via CLI
- Tested with the example
echo.trampolined.wasmfunction
note: todo - test everything else is still working as expected