Skip to content

Commit 578f5aa

Browse files
committed
check if local session
1 parent 6307581 commit 578f5aa

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

core/inspector.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ impl JsRuntimeInspector {
332332

333333
loop {
334334
'session_loop: loop {
335+
// TODO(bartlomieju): this handshake step is BS, remove it
335336
// Do one "handshake" with a newly connected session at a time.
336337
if let Some(mut session) = sessions.handshake.take() {
337338
let poll_result = session.poll_next_unpin(cx);
@@ -423,7 +424,9 @@ impl JsRuntimeInspector {
423424
/// established a websocket connection.
424425
pub fn wait_for_session(&mut self) {
425426
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
427430
if self.sessions.get_mut().established.is_empty() {
428431
self.flags.get_mut().waiting_for_session = true;
429432
let _ = self.poll_sessions(None).unwrap();
@@ -442,6 +445,9 @@ impl JsRuntimeInspector {
442445
/// execution.
443446
pub fn wait_for_session_and_break_on_next_statement(&mut self) {
444447
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
445451
match self.sessions.get_mut().established.iter_mut().next() {
446452
Some(session) => break session.break_on_next_statement(),
447453
None => {
@@ -566,23 +572,32 @@ impl SessionContainer {
566572

567573
fn sessions_state(&self) -> SessionsState {
568574
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(),
570578
has_blocking: self
571579
.established
572580
.iter()
581+
.chain(self.local.values())
573582
.any(|s| matches!(s.kind, InspectorSessionKind::Blocking)),
574583
has_nonblocking: self
575584
.established
576585
.iter()
586+
.chain(self.local.values())
577587
.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+
}),
586601
}
587602
}
588603

0 commit comments

Comments
 (0)