Skip to content

Commit

Permalink
summonerd: don't bail out on bad contribution data
Browse files Browse the repository at this point in the history
The better code pattern for this would be to blanket-handle errors in the method, but at the moment it seems better to just fix the current issue.
  • Loading branch information
hdevalence committed Nov 25, 2023
1 parent 14e65e0 commit 373226a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tools/summonerd/src/participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,14 @@ impl Participant {
tracing::info!("got Contribution message from participant, deserializing...");
let deserialized =
tokio::task::spawn_blocking(move || P::deserialize_contribution(contribution))
.await??;
Ok(Some(deserialized))
// Only bubble up JoinHandle errors here...
.await?;
// ... so that if there's a deserialization error we return None.
// (ideally this code would be structured differently, so that we didn't have to carefully
// distinguish between different kinds of errors, and just treat any error occurring in the context
// of a participant as a failed contribution, but we don't want to do any more refactoring than
// is necessary to this code.)
Ok(deserialized.ok())
} else {
Ok(None)
}
Expand Down

0 comments on commit 373226a

Please sign in to comment.