Skip to content

Commit

Permalink
fix(rs-wit-bindgen): do not fail on async I/O errors
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <[email protected]>
  • Loading branch information
rvolosatovs committed Jul 5, 2024
1 parent bea73e2 commit ac39c7c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/wit-bindgen-rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wit-bindgen-wrpc-rust"
version = "0.4.0"
version = "0.4.1"
description = """
Rust bindings generator for wRPC, typically used through
the `wit-bindgen-wrpc` crate's `generate!` macro.
Expand Down
14 changes: 8 additions & 6 deletions crates/wit-bindgen-rust/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,30 +337,32 @@ pub async fn serve_interface<T: {wrpc_transport}::Serve, U>(
self.src,
r#"
).await {{
Ok(returns) => {{
Ok(results) => {{
match tx("#,
);
if func.results.len() == 1 {
// wrap single-element returns into a tuple for correct indexing
self.push_str("(returns,)");
// wrap single-element results into a tuple for correct indexing
self.push_str("(results,)");
} else {
self.push_str("returns");
self.push_str("results");
}
uwrite!(
self.src,
r#"
).await {{
Ok(()) => {{
if let Some(rx) = rx {{
rx.await??;
if let Err(err) = rx.await? {{
{tracing}::warn!(?err, "failed to receive async `{instance}.{wit_name}` invocation parameters");
}}
}}
continue;
}}
Err(err) => {{
if let Some(rx) = rx {{
rx.abort();
}}
{tracing}::warn!(?err, "failed to send returns");
{tracing}::warn!(?err, "failed to transmit `{instance}.{wit_name}` invocation results");
}}
}}
}},
Expand Down

0 comments on commit ac39c7c

Please sign in to comment.