@@ -53,7 +53,13 @@ impl WasmRouteHandler {
53
53
self . set_up_runtime_environment ( matched_route, req, request_body, request_context, global_context, logging_key) ?;
54
54
self . spawn_wasm_instance ( instance, store, stream_writer. clone ( ) ) ;
55
55
56
- let response = compose_response ( stream_writer) . await ?; // TODO: handle errors
56
+ let response = match compose_response ( stream_writer) . await {
57
+ Ok ( r) => r,
58
+ Err ( e) => {
59
+ tracing:: error!( "Error parsing guest output into HTTP response: {}" , e) ;
60
+ internal_error ( "internal error calling application" )
61
+ }
62
+ } ;
57
63
58
64
tokio:: task:: yield_now ( ) . await ;
59
65
@@ -87,11 +93,18 @@ impl WasmRouteHandler {
87
93
let entrypoint = self . entrypoint . clone ( ) ;
88
94
let wasm_module_name = self . wasm_module_name . clone ( ) ;
89
95
96
+ // This is fire and forget, so there's a limited amount of error handling we
97
+ // can do.
90
98
tokio:: spawn ( async move {
91
99
match run_prepared_wasm_instance ( instance, store, & entrypoint, & wasm_module_name) {
92
- Ok ( ( ) ) => stream_writer . done ( ) . unwrap ( ) , // TODO: <--
93
- Err ( e) => tracing:: error!( "oh no {}" , e) , // TODO: behaviour? message? MESSAGE, IVAN?!
100
+ Ok ( ( ) ) => ( ) ,
101
+ Err ( e) => tracing:: error!( "Error running Wasm module: {}" , e) ,
94
102
} ;
103
+ // TODO: should we attempt to write an error response to the StreamWriter here?
104
+ match stream_writer. done ( ) {
105
+ Ok ( ( ) ) => ( ) ,
106
+ Err ( e) => tracing:: error!( "Error marking Wasm output as done: {}" , e) ,
107
+ }
95
108
} ) ;
96
109
}
97
110
0 commit comments