Skip to content

Commit

Permalink
Don't panic on unknown token_id in gRPC callbacks. (#210)
Browse files Browse the repository at this point in the history
Signed-off-by: erikness-doordash <[email protected]>
  • Loading branch information
erikness-doordash authored Nov 9, 2023
1 parent 6b47aec commit 9b4b4a5
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,14 @@ impl Dispatcher {
}

fn on_grpc_receive_initial_metadata(&self, token_id: u32, headers: u32) {
let context_id = *self
.grpc_streams
.borrow_mut()
.get(&token_id)
.expect("invalid token_id");
let context_id = match self.grpc_streams.borrow_mut().get(&token_id) {
Some(id) => *id,
None => {
// TODO: change back to a panic once underlying issue is fixed.
trace!("on_grpc_receive_initial_metadata: invalid token_id");
return;
}
};

if let Some(http_stream) = self.http_streams.borrow_mut().get_mut(&context_id) {
self.active_id.set(context_id);
Expand Down Expand Up @@ -480,16 +483,20 @@ impl Dispatcher {
root.on_grpc_stream_message(token_id, response_size);
}
} else {
panic!("invalid token_id")
// TODO: change back to a panic once underlying issue is fixed.
trace!("on_grpc_receive_initial_metadata: invalid token_id");
}
}

fn on_grpc_receive_trailing_metadata(&self, token_id: u32, trailers: u32) {
let context_id = *self
.grpc_streams
.borrow_mut()
.get(&token_id)
.expect("invalid token_id");
let context_id = match self.grpc_streams.borrow_mut().get(&token_id) {
Some(id) => *id,
None => {
// TODO: change back to a panic once underlying issue is fixed.
trace!("on_grpc_receive_trailing_metadata: invalid token_id");
return;
}
};

if let Some(http_stream) = self.http_streams.borrow_mut().get_mut(&context_id) {
self.active_id.set(context_id);
Expand Down

0 comments on commit 9b4b4a5

Please sign in to comment.