nerdachse edited issue #9331:
I am experimenting with a
wasmtime
powered plugin system.So far everything works like a charm. Thanks a bunch for your awesome work!
I am using the component model, wasmtime-wasi in an async fashion!
Now inside a plugin/component I do this:
impl OnRequestGuest for Component { fn onwsrequest(msg: String) { print(NAME, &format!("A received a message from host: {msg}")); //publish("thanks_for_watching"); } fn onrequest(req: Request) -> Response { let Request { head: Parts { uri, method, .. }, .. } = req; let h1 = format!("Thanks for your call to {uri} via {method}!"); let html = leptos::ssr::render_to_string(move || { view! { <h1>{h1}</h1> <p>"This site was built with leptos and love!"</p> } }); let root = build_response( uri.clone(), method.clone(), vec![], html.as_bytes().to_vec(), ); let html = leptos::ssr::render_to_string(move || { view! { <h1>Welcome to Ladida!</h1> <p>Here, the future is forged!</p> } }); let ladida = build_response(uri.clone(), method, vec![], html.as_bytes().to_vec()); let mut router = matchit::Router::new(); //router.insert("/", root).unwrap(); router.insert("/ladida", ladida).unwrap(); // //router.at(&uri).unwrap().value.clone(); root } }
As soon as I enable the line:
router.at(&uri).unwrap().value.clone();
it fails with
2024-09-29T22:32:43.061351Z ERROR simple_host::pluginsystem::routes: An error occurred during the onrequest call for plugin@".../compiled_plugins_folder/my_plugin.wasm": error while executing at wasm backtrace: 0: 0x1450c - <unknown>!<wasm function 231> 1: 0x13a02 - <unknown>!<wasm function 208> 2: 0x14b6f - <unknown>!<wasm function 238> 3: 0x14ae0 - <unknown>!<wasm function 237> 4: 0xda0e - <unknown>!<wasm function 123> 5: 0xcc83 - <unknown>!<wasm function 100> 6: 0x4b7c - <unknown>!<wasm function 68> 7: 0x96c0 - <unknown>!<wasm function 86> ``` **when the host and my usage of wasmtime was still `sync` I got another error, saying something like `Cannot instantiate new runtime while in runtime` (usage like `block_on` not allowed) or something along these lines.** Can you explain the error and what I can do to circumvent it? Thank you very much! ~~~
nerdachse edited issue #9331:
Nevermind, it was my error alone. Sorry for the noise!
nerdachse closed issue #9331:
Nevermind, it was my error alone. Sorry for the noise!
Last updated: Nov 22 2024 at 16:03 UTC