Skip to content

Commit 7667d4b

Browse files
committed
Make errors slightly less worse
1 parent 055a87d commit 7667d4b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/handlers.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ impl WasmRouteHandler {
5353
self.set_up_runtime_environment(matched_route, req, request_body, request_context, global_context, logging_key)?;
5454
self.spawn_wasm_instance(instance, store, stream_writer.clone());
5555

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+
};
5763

5864
tokio::task::yield_now().await;
5965

@@ -87,11 +93,18 @@ impl WasmRouteHandler {
8793
let entrypoint = self.entrypoint.clone();
8894
let wasm_module_name = self.wasm_module_name.clone();
8995

96+
// This is fire and forget, so there's a limited amount of error handling we
97+
// can do.
9098
tokio::spawn(async move {
9199
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),
94102
};
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+
}
95108
});
96109
}
97110

0 commit comments

Comments
 (0)