wapc / wapc-rs

waPC Rust monorepo
Apache License 2.0
75 stars 9 forks source link

wasmtime provider bump #12

Closed flavio closed 2 years ago

flavio commented 2 years ago

Upgrade the wasmtime-provide to use latest stable release of wasmtime: v0.40. This is a minor relase of wasmtime, which happens to break some public APIs.

This PR fixes the compilation issues introduces by the breaking changes.

The most important one is the one fixed by 8ed2e19991530d91b2014e5ab899dca4225df8cd . This commit causes wasmtime_provider::errors::Error to drop on variant and gain a new one. Because of this change, I think it would be better to tag the next release of wasmtime_provider as 1.1.0 instead of doing a patch relase.

I tried hard to avoid this breaking change, but that doesn't seem possible.

This is the commit message that explains what happened.

Updating to wasmtime 0.40 breaks waasmtime-provider own Error enum when the wasi feature is disabled.

When the wasi feature is disabled, the wasi_common::Error is no longer defined. That causes wasmtime_provider::Error::WasiError variant definition to break.

It is possible to hide this enum variant definition behind a cfg check, and prevent its definition when the wasi feature is disabled. However, when this is done, the code will break in some other parts when the ? operator attempts to convert a anyhow::Error into a wasmtime_provider::Error. The wasmtime create doesn't define a custom error type, but instead has many APIs returning a anyhow::Result (which is a Result returning a anyhow::Error type of error). This includes methods like wasmtime::Module.new.

This compilation error can be solved by defining a new variant inside of wasmtime_provider::Error, which transparently maps anyhow::Error. Unfortunately, this breaks the compilation when the wasi feature is enabled. The compilation fails because there are two conflicting implementations of std::convert::From<anyhow::Error>.

This commit removes the wasmtime_provider::Error::WasiError variant and introduces a Generic variant that can handle all anyhow::Error transformations.

jsoverson commented 2 years ago

Thanks @flavio for dealing with the Error headache

flavio commented 2 years ago

Thanks for the fast review and release!