File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,10 @@ class MicrobitRadioBridgeConnectionImpl
83
83
const currentStatus = this . status ;
84
84
if ( e . status !== ConnectionStatus . CONNECTED ) {
85
85
this . setStatus ( e . status ) ;
86
- this . serialSession ?. dispose ( ) ;
86
+ if ( this . serialSessionOpen ) {
87
+ // If the session is already closed we don't need to dispose.
88
+ this . serialSession ?. dispose ( ) ;
89
+ }
87
90
} else {
88
91
this . status = ConnectionStatus . DISCONNECTED ;
89
92
if (
Original file line number Diff line number Diff line change @@ -564,6 +564,10 @@ class MicrobitWebUSBConnectionImpl
564
564
protected eventActivated ( type : string ) : void {
565
565
switch ( type as keyof SerialConnectionEventMap ) {
566
566
case "serialdata" : {
567
+ if ( this . addedListeners . serialdata ) {
568
+ this . addedListeners . serialdata ++ ;
569
+ break ;
570
+ }
567
571
// Prevent starting serial when flashing.
568
572
if ( ! this . flashing ) {
569
573
this . startSerialInternal ( ) ;
@@ -578,8 +582,10 @@ class MicrobitWebUSBConnectionImpl
578
582
protected async eventDeactivated ( type : string ) {
579
583
switch ( type as keyof SerialConnectionEventMap ) {
580
584
case "serialdata" : {
581
- this . stopSerialInternal ( ) ;
582
585
this . addedListeners . serialdata -- ;
586
+ if ( ! this . addedListeners . serialdata ) {
587
+ this . stopSerialInternal ( ) ;
588
+ }
583
589
break ;
584
590
}
585
591
}
You can’t perform that action at this time.
0 commit comments