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:

  1. The input is automatically transcoded from JSON to MessagePack
  2. The Wasm API provider (shopify_function_v0.0.1.wasm) is loaded
  3. The output is automatically transcoded from MessagePack back to JSON

For output handling:

  1. Locates the actual MessagePack data in the output stream
  2. Extracts only the relevant MessagePack portion for processing
  3. 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.wasm function

note: todo - test everything else is still working as expected