wasmtime
wasmtime copied to clipboard
wasm trap: cannot enter component instance
hey there how can I sort of clone a wasm in execution the issue is I call the one of the imported function (1st function) from guest on host ( wasm is in execution as of now) Now that imported function from guest to wasm calls another function which is exported by host to guest but this function ( exported function on host) again needs to call different (let's call it 2nd function) imported function from guest and this is the issue . During this whole process wasm is in execution and how can I call the 2nd function ?
I tried storing reactor(component) and store in static variable , reactor works fine as it only requires reference while function calling but issue is in case of store while calling imported function I need to provide mutable reference to store . Which I can't as at a time I can't have two mutable reference . For sharing mutable reference - I created a static option containing Store and passed the mutable reference to function like so
let result: Result<http_types::Response, anyhow::Error> =
guest.call_handle_request(&mut *store, &request).await; (1st function) (in main function where I instantiate component)
let result = guest.call_jsonnet_call_native_func(&mut *store, &self.0, "")
.await (2nd function) (in some other exported function which component calls as a result of calling above imported function)
But in above case I am getting error
wasm trap: cannot enter component instance
I tried creating new store but then I get some different error , if I use that store with reference of Reactor .
Please help me , I don't want to use core wasm modules . Nor I think I will be able to break the wasm module in two components (as I my wasm module is basically quickjs runtime along with js code the wasm is generated by cargo building to target wasm32-wasi the quickjs_wasm_rs context (javy approach, fermyon spin approach) .