Skip to content

Commit

Permalink
include context on host errors
Browse files Browse the repository at this point in the history
Signed-off-by: Connor Smith <connor.smith.256@gmail.com>
  • Loading branch information
connorsmith256 committed Sep 7, 2023
1 parent 94c0fa4 commit 0388f31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
14 changes: 7 additions & 7 deletions crates/core/src/chunking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use async_nats::jetstream::{
object_store::{Config, ObjectStore},
Context as JetstreamContext,
};
use futures::TryFutureExt;
use tokio::io::{AsyncRead, AsyncReadExt};
use tracing::{debug, error, instrument};

Expand Down Expand Up @@ -73,16 +72,17 @@ impl ChunkEndpoint {
.await
.map_err(|e| anyhow!(e).context("failed to get object store"))?;
debug!(invocation_id = %inv_id, "chunkify starting to receive");
let mut obj = store.get(inv_id).await.map_err(|e| {
anyhow!(e).context("failed to receive chunked stream for inv {inv_id}: {e}")
})?;
let mut obj = store
.get(inv_id)
.await
.context("failed to receive chunked stream")?;
obj.read_to_end(&mut result)
.map_err(|e| anyhow!(e).context("failed to read chunked stream for inv {inv_id}: {e}"))
.await?;
.await
.context("failed to read chunked stream")?;
if let Err(e) = store.delete(inv_id).await {
// not deleting will be a non-fatal error for the receiver,
// if all the bytes have been received
error!(invocation_id = %inv_id, error = %e, "failed to delete chunks for inv");
error!(invocation_id = %inv_id, error = %e, "failed to delete chunks");
}
Ok(result)
}
Expand Down
5 changes: 2 additions & 3 deletions crates/runtime/src/actor/module/wasmbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ fn write_bytes<T>(
}

#[instrument(skip(store, err))]
fn set_host_error(store: &mut wasmtime::Caller<'_, super::Ctx>, err: impl ToString) {
let err = err.to_string();
fn set_host_error(store: &mut wasmtime::Caller<'_, super::Ctx>, err: String) {
trace!(err, "set host error");
store.data_mut().wasmbus.host_error = Some(err);
}
Expand Down Expand Up @@ -308,7 +307,7 @@ async fn host_call(
Ok(wasm::SUCCESS)
}
Err(err) => {
set_host_error(&mut store, err);
set_host_error(&mut store, format!("{err:#}"));
Ok(wasm::ERROR)
}
}
Expand Down

0 comments on commit 0388f31

Please sign in to comment.