Comments (5)
just had more tests and found it caused by following line about config. Take a look at The manifest but still cannot figure out how to use it for testing :)
// remove to fix runtime error
// config::get("thing").expect("'thing' key set in config");
let config = String::from("something");
from extism.
Did you copy paste the code from https://extism.org/docs/write-a-plugin/rust-pdk ?
I ran your code through the extism cli:
echo "Hello World" | extism call wasm_web_plugin.wasm count_vowels
Traceback (most recent call last):
File "/Users/ben/.local/bin/extism", line 558, in <module>
main()
File "/Users/ben/.local/bin/extism", line 553, in main
r = plugin.call(args.function, input, parse=None)
File "/opt/homebrew/lib/python3.10/site-packages/extism/extism.py", line 201, in call
self._check_error(
File "/opt/homebrew/lib/python3.10/site-packages/extism/extism.py", line 183, in _check_error
raise Error(ffi.string(error).decode())
extism.extism.Error: Call failed
Caused by:
0: error while executing at wasm backtrace:
0: 0x74c3 - <unknown>!__rust_start_panic
1: 0x74b7 - <unknown>!rust_panic
2: 0x7487 - <unknown>!std::panicking::rust_panic_with_hook::he04cb00575f2a1e3
3: 0x6b18 - <unknown>!std::panicking::begin_panic_handler::{{closure}}::hb733f0aa505760cf
4: 0x6a45 - <unknown>!std::sys_common::backtrace::__rust_end_short_backtrace::h6beefa0bcab220bc
5: 0x70db - <unknown>!rust_begin_unwind
6: 0x803a - <unknown>!core::panicking::panic_fmt::h586d720a90aa8503
7: 0x9134 - <unknown>!core::panicking::panic_display::he96fafaefe672510
8: 0x90ae - <unknown>!core::panicking::panic_str::h8b2f06f6f011655d
9: 0x907c - <unknown>!core::option::expect_failed::h1e9a9cbb22bbd6ac
10: 0xcf4 - <unknown>!count_vowels
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable to may show more debugging information
1: wasm trap: wasm `unreachable` instruction executed
The line of interest to you should be:
9: 0x907c - <unknown>!core::option::expect_failed::h1e9a9cbb22bbd6ac
Keep in mind that any of these lines may trap and just there to demonstrate the API:
let a = var::get("a")?.expect("variable 'a' set");
let a = String::from_utf8(a).expect("string from varible value");
let config = config::get("thing").expect("'thing' key set in config");
Here is a simplified version of that example:
use extism_pdk::*;
use serde::Serialize;
const VOWELS: &[char] = &['a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U'];
#[derive(Serialize)]
struct TestOutput {
pub count: i32,
}
#[plugin_fn]
pub unsafe fn count_vowels(input: String) -> FnResult<Json<TestOutput>> {
let mut count = 0;
for ch in input.chars() {
if VOWELS.contains(&ch) {
count += 1;
}
}
let output = TestOutput {
count,
};
Ok(Json(output))
}
from extism.
@bhelx
Thanks for your reply.I had already modified my code and passed the test in playgound.
My current question is about where and how to privide manifest/config.
from extism.
@piaoger currently there is no support to add a config through the playground, but you can do it via the CLI using --set-config
to pass a map of key/value pairs, or --config
to set a single key=value pair.
An example of using --set-config
can be seen here:
https://github.com/extism/assemblyscript-pdk/blob/main/.github/workflows/ci.yml#L55
from extism.
@nilslice thanks for the information :)
from extism.
Related Issues (20)
- runtime: update `Plugin::function_extists` and `extism_plugin_function_exists` to check the type of the functions too HOT 4
- derive that forwards From/ToBytes to specific encoding HOT 4
- runtime: wasi preview2 HOT 10
- How do I silence debug logs in the extism crate? HOT 1
- discord link in readme is expired HOT 6
- Add support for multiple arguments
- Pass plug-in ID into `set_log_callback` callback function
- Error: http: request body too large (recovered by wazero) HOT 5
- option for a WASM instr limit per call HOT 1
- look into calling `_initialize` on all linked plugins when initializing the guest runtime, not just the main module HOT 1
- Question about plugin return types HOT 3
- Direct disk/filesystem access HOT 4
- Cost of the function call throught host/guest boundary HOT 8
- Synchronizing the content of `wasm` folder HOT 2
- feat: add manifest field to limit the size of Extism vars HOT 1
- Extism gem fails to load on Ruby 3.3.0 on macOS HOT 6
- Async / Await / Generators / Coroutines in Plugins HOT 3
- How to unload a plugin? HOT 3
- Could we get access to the `id` on `CurrentPlugin`
- add a feature to control which wasm backend is enabled? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extism.