tessi / wasmex

Execute WebAssembly from Elixir
MIT License
562 stars 32 forks source link

Out of fuel identification #617

Open samuelmanzanera opened 3 months ago

samuelmanzanera commented 3 months ago

Since wasmtime supports fuel consumption, we have the possibility to allow this feature from the engine. However when the execution fails due to out of fuel the error message is not particularly clear. We don't know if the error is related to module error (i.e. unreachable state) or fuel consumption.

Is it possible to return a custom error when the fuel is completely used and the flow is stopped ?

Thanks

tessi commented 3 months ago

Hey @samuelmanzanera

I agree that it's hard to find out why exactly a wasm call fails. After some poking around in wasmtime's APIs I found a good approach on how to get more information out in some error scenarios. Do you mind giving this PR a try and see if it solves the issue? https://github.com/tessi/wasmex/pull/620

It's just added more information to the error reason string. It might be a bit nicer to have a separate atom for this for matching, but that would be a bit bigger of a refactor :)