@@ -468,24 +468,26 @@ impl Dispatcher {
468
468
hostcalls:: set_effective_context ( context_id) . unwrap ( ) ;
469
469
root. on_grpc_call_response ( token_id, 0 , response_size) ;
470
470
}
471
- } else if let Some ( context_id) = self . grpc_streams . borrow_mut ( ) . get ( & token_id) {
472
- let context_id = * context_id;
473
- if let Some ( http_stream) = self . http_streams . borrow_mut ( ) . get_mut ( & context_id) {
474
- self . active_id . set ( context_id) ;
475
- hostcalls:: set_effective_context ( context_id) . unwrap ( ) ;
476
- http_stream. on_grpc_stream_message ( token_id, response_size) ;
477
- } else if let Some ( stream) = self . streams . borrow_mut ( ) . get_mut ( & context_id) {
478
- self . active_id . set ( context_id) ;
479
- hostcalls:: set_effective_context ( context_id) . unwrap ( ) ;
480
- stream. on_grpc_stream_message ( token_id, response_size) ;
481
- } else if let Some ( root) = self . roots . borrow_mut ( ) . get_mut ( & context_id) {
482
- self . active_id . set ( context_id) ;
483
- hostcalls:: set_effective_context ( context_id) . unwrap ( ) ;
484
- root. on_grpc_stream_message ( token_id, response_size) ;
485
- }
486
471
} else {
487
- // TODO: change back to a panic once underlying issue is fixed.
488
- trace ! ( "on_grpc_receive_initial_metadata: invalid token_id" ) ;
472
+ let context_id = self . grpc_streams . borrow ( ) . get ( & token_id) . cloned ( ) ;
473
+ if let Some ( context_id) = context_id {
474
+ if let Some ( http_stream) = self . http_streams . borrow_mut ( ) . get_mut ( & context_id) {
475
+ self . active_id . set ( context_id) ;
476
+ hostcalls:: set_effective_context ( context_id) . unwrap ( ) ;
477
+ http_stream. on_grpc_stream_message ( token_id, response_size) ;
478
+ } else if let Some ( stream) = self . streams . borrow_mut ( ) . get_mut ( & context_id) {
479
+ self . active_id . set ( context_id) ;
480
+ hostcalls:: set_effective_context ( context_id) . unwrap ( ) ;
481
+ stream. on_grpc_stream_message ( token_id, response_size) ;
482
+ } else if let Some ( root) = self . roots . borrow_mut ( ) . get_mut ( & context_id) {
483
+ self . active_id . set ( context_id) ;
484
+ hostcalls:: set_effective_context ( context_id) . unwrap ( ) ;
485
+ root. on_grpc_stream_message ( token_id, response_size) ;
486
+ }
487
+ } else {
488
+ // TODO: change back to a panic once underlying issue is fixed.
489
+ trace ! ( "on_grpc_receive_initial_metadata: invalid token_id" ) ;
490
+ }
489
491
}
490
492
}
491
493
0 commit comments