Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't hard-error on unreadable messages #103

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,15 @@ impl EventHandler for Handler {
/// window, then Galileo will respond instructing the user to wait longer.
async fn message(&self, ctx: Context, message: Message) {
// Check whether we should proceed.
let message_info = MessageInfo::new(&message, &ctx).unwrap();
let message_info = match MessageInfo::new(&message, &ctx) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great 👍

eventually it could be cool to expose a metric counting messages observed / parsed, but that's another item for the rainy day bucket 🙂

Ok(m) => m,
Err(e) => {
// We can't return an error, but we also can't proceed, so log the error
// and early-return to bail out.
tracing::error!(%e, "failed to get message info for message");
return;
}
};
if !self.should_send(&ctx, &message_info).await {
return;
}
Expand Down
6 changes: 5 additions & 1 deletion src/tracing.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::io::IsTerminal as _;
use tracing_subscriber::{prelude::*, EnvFilter};

/// Initializes a tracing subscriber.
pub(crate) fn init_subscriber() -> anyhow::Result<()> {
let fmt_layer = tracing_subscriber::fmt::layer().with_target(true);
let fmt_layer = tracing_subscriber::fmt::layer()
.with_target(true)
.with_ansi(std::io::stderr().is_terminal())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging to stderr feels mildly surprising to me, but i don't have a strong opinion about this 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, subjective, I guess. Putting on my sysadmin hat, I feel strongly that "stdout is for output, stderr is for logging and diagnostics." But in the case of galileo serve, where the only output is logging, stdout is probably fine. Old habits die hard.

.with_writer(std::io::stderr);
let filter_layer = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("info"))?
// Force disabling of r1cs log messages, otherwise the `ark-groth16` crate
Expand Down