diff --git a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs index fdd67343..d22c9d43 100644 --- a/kinode/packages/kns_indexer/kns_indexer/src/lib.rs +++ b/kinode/packages/kns_indexer/kns_indexer/src/lib.rs @@ -148,7 +148,7 @@ fn main(our: Address, mut state: State) -> anyhow::Result<()> { ); // if contract address changed from a previous run, reset state if state.contract_address != contract_address { - println!("resetting state for some reason."); + println!("kns_indexer: contract address changed, re-indexing"); state = State { contract_address: contract_address.clone(), names: HashMap::new(), diff --git a/kinode/packages/terminal/m/src/lib.rs b/kinode/packages/terminal/m/src/lib.rs index 34a468d6..8bf3157c 100644 --- a/kinode/packages/terminal/m/src/lib.rs +++ b/kinode/packages/terminal/m/src/lib.rs @@ -1,5 +1,7 @@ use clap::{Arg, Command}; -use kinode_process_lib::{await_next_request_body, call_init, println, Address, Request, Response}; +use kinode_process_lib::{ + await_next_request_body, call_init, println, Address, Request, Response, SendErrorKind, +}; use regex::Regex; wit_bindgen::generate!({ @@ -78,10 +80,24 @@ fn init(_our: Address) { println!("m: awaiting response for {}s", s); match req.send_and_await_response(*s).unwrap() { Ok(res) => { - let _ = Response::new().body(res.body()).send(); + // TODO piping is broken. Patching it by just printing the response + // let _ = Response::new().body(res.body()).send(); + if let Ok(txt) = std::str::from_utf8(&res.body()) { + println!("{txt}"); + } else { + println!("{:?}", res.body()); + } } Err(e) => { - println!("m: SendError: {:?}", e.kind); + println!( + "m: {}", + match e.kind { + SendErrorKind::Timeout => + "target did not send Response in time, try increasing the await time", + SendErrorKind::Offline => + "failed to send message because the target is offline", + } + ); } } } diff --git a/kinode/src/kernel/mod.rs b/kinode/src/kernel/mod.rs index 574afd64..d39856c9 100644 --- a/kinode/src/kernel/mod.rs +++ b/kinode/src/kernel/mod.rs @@ -917,8 +917,12 @@ pub async fn kernel( .send(t::Printout { verbosity: 0, content: format!( - "event loop: don't have {} amongst registered processes (got net error for it)", + "event loop: {} failed to deliver a message {}; sender has already terminated", wrapped_network_error.source.process, + match wrapped_network_error.error.kind { + t::SendErrorKind::Timeout => "due to timeout", + t::SendErrorKind::Offline => "because the receiver is offline", + }, ) }) .await; @@ -977,8 +981,17 @@ pub async fn kernel( .send(t::Printout { verbosity: 0, content: format!( - "event loop: don't have {} amongst registered processes (got message for it from network)", + "event loop: got {} from network for {}, but process does not exist{}", + match kernel_message.message { + t::Message::Request(_) => "Request", + t::Message::Response(_) => "Response", + }, kernel_message.target.process, + match kernel_message.message { + t::Message::Request(_) => "", + t::Message::Response(_) => + "\nhint: if you are using `m`, try awaiting the Response: `m --await 5 ...`", + } ) }) .await; @@ -1093,7 +1106,12 @@ pub async fn kernel( .send(t::Printout { verbosity: 0, content: format!( - "event loop: don't have {:?} amongst registered processes, got message for it: {}", + "event loop: got {} from {:?} for {:?}, but target doesn't exist (perhaps it terminated): {}", + match kernel_message.message { + t::Message::Request(_) => "Request", + t::Message::Response(_) => "Response", + }, + kernel_message.source.process, kernel_message.target.process, kernel_message, )