@@ -332,6 +332,7 @@ impl JsRuntimeInspector {
332
332
333
333
loop {
334
334
' session_loop: loop {
335
+ // TODO(bartlomieju): this handshake step is BS, remove it
335
336
// Do one "handshake" with a newly connected session at a time.
336
337
if let Some ( mut session) = sessions. handshake . take ( ) {
337
338
let poll_result = session. poll_next_unpin ( cx) ;
@@ -423,7 +424,9 @@ impl JsRuntimeInspector {
423
424
/// established a websocket connection.
424
425
pub fn wait_for_session ( & mut self ) {
425
426
loop {
426
- // TODO: doesn't account for "local" sessions
427
+ // TODO: doesn't account for "local" sessions - which might be okay,
428
+ // because if we're waiting, then there's no way a local
429
+ // session can be created at this point
427
430
if self . sessions . get_mut ( ) . established . is_empty ( ) {
428
431
self . flags . get_mut ( ) . waiting_for_session = true ;
429
432
let _ = self . poll_sessions ( None ) . unwrap ( ) ;
@@ -442,6 +445,9 @@ impl JsRuntimeInspector {
442
445
/// execution.
443
446
pub fn wait_for_session_and_break_on_next_statement ( & mut self ) {
444
447
loop {
448
+ // TODO: doesn't account for "local" sessions - which might be okay,
449
+ // because if we're waiting, then there's no way a local
450
+ // session can be created at this point
445
451
match self . sessions . get_mut ( ) . established . iter_mut ( ) . next ( ) {
446
452
Some ( session) => break session. break_on_next_statement ( ) ,
447
453
None => {
@@ -566,23 +572,32 @@ impl SessionContainer {
566
572
567
573
fn sessions_state ( & self ) -> SessionsState {
568
574
SessionsState {
569
- has_active : !self . established . is_empty ( ) || self . handshake . is_some ( ) ,
575
+ has_active : !self . established . is_empty ( )
576
+ || self . handshake . is_some ( )
577
+ || !self . local . is_empty ( ) ,
570
578
has_blocking : self
571
579
. established
572
580
. iter ( )
581
+ . chain ( self . local . values ( ) )
573
582
. any ( |s| matches ! ( s. kind, InspectorSessionKind :: Blocking ) ) ,
574
583
has_nonblocking : self
575
584
. established
576
585
. iter ( )
586
+ . chain ( self . local . values ( ) )
577
587
. any ( |s| matches ! ( s. kind, InspectorSessionKind :: NonBlocking { .. } ) ) ,
578
- has_nonblocking_wait_for_disconnect : self . established . iter ( ) . any ( |s| {
579
- matches ! (
580
- s. kind,
581
- InspectorSessionKind :: NonBlocking {
582
- wait_for_disconnect: true
583
- }
584
- )
585
- } ) ,
588
+ has_nonblocking_wait_for_disconnect : self
589
+ . established
590
+ . iter ( )
591
+ // TODO(bartlomieju): not sure if that's possible in "Local" sessions - check it
592
+ . chain ( self . local . values ( ) )
593
+ . any ( |s| {
594
+ matches ! (
595
+ s. kind,
596
+ InspectorSessionKind :: NonBlocking {
597
+ wait_for_disconnect: true
598
+ }
599
+ )
600
+ } ) ,
586
601
}
587
602
}
588
603
0 commit comments