diff --git a/src/dispatcher.rs b/src/dispatcher.rs index b562201c..4d1f16fa 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -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); @@ -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);