@@ -14,7 +14,7 @@ use std::time::{Duration, Instant};
1414use tokio:: io:: { stderr, stdin, stdout} ;
1515use tokio:: sync:: Notify ;
1616use wasmtime:: component:: { Component , Instance , InstancePre , Linker } ;
17- use wasmtime:: { AsContextMut , Engine , Store , StoreLimits , UpdateDeadline } ;
17+ use wasmtime:: { Engine , Store , StoreLimits , UpdateDeadline } ;
1818use wasmtime_wasi:: p2:: { IoView , StreamError , StreamResult , WasiCtx , WasiCtxBuilder , WasiView } ;
1919use wasmtime_wasi_http:: bindings as p2;
2020use wasmtime_wasi_http:: io:: TokioIo ;
@@ -980,17 +980,15 @@ async fn handle_request(
980980 . await
981981 } )
982982 . await ???;
983- let ( res, tx, io) =
984- wasmtime_wasi_http:: p3:: Response :: resource_into_http ( & mut store, res) ?;
983+ let ( res, io) = wasmtime_wasi_http:: p3:: Response :: resource_into_http ( & mut store, res) ?;
985984 tokio:: task:: spawn ( async move {
986- if let Some ( io) = io {
987- let closure = instance. run ( & mut store, io) . await ?;
988- closure ( store. as_context_mut ( ) ) ?;
989- }
990- // TODO: Report transmit errors
991- if let Some ( tx) = tx {
992- instance. run ( & mut store, tx. write ( Ok ( ( ) ) ) ) . await ?;
993- }
985+ instance
986+ . run_with ( & mut store, async |store| {
987+ // TODO: Report transmit errors
988+ let guest_io_result = async { Ok ( ( ) ) } ;
989+ io. run ( store, guest_io_result) . await
990+ } )
991+ . await ??;
994992
995993 write_profile ( & mut store) ;
996994 drop ( epoch_thread) ;
0 commit comments