@@ -42,6 +42,7 @@ import {
42
42
Cancelled ,
43
43
Processing ,
44
44
isActive ,
45
+ isOk ,
45
46
isProcessing ,
46
47
hasUUID ,
47
48
BlockModel
@@ -529,6 +530,13 @@ export default class ScrollableTerminal extends React.PureComponent<Props, State
529
530
return ! this . hasPinned ( curState . splits [ availableSplit ] ) ? availableSplit : 0
530
531
}
531
532
533
+ // If the block has watchable response, abort the job
534
+ private removeWatchableBlock ( block : BlockModel ) {
535
+ if ( isOk ( block ) && isWatchable ( block . response ) ) {
536
+ block . response . watch . abort ( )
537
+ }
538
+ }
539
+
532
540
/**
533
541
* Remove the given split (identified by `sbuuid`) from the state.
534
542
*
@@ -537,6 +545,8 @@ export default class ScrollableTerminal extends React.PureComponent<Props, State
537
545
this . setState ( curState => {
538
546
const idx = this . findSplit ( this . state , sbuuid )
539
547
if ( idx >= 0 ) {
548
+ curState . splits [ idx ] . blocks . forEach ( this . removeWatchableBlock )
549
+
540
550
const splits = curState . splits . slice ( 0 , idx ) . concat ( curState . splits . slice ( idx + 1 ) )
541
551
542
552
if ( splits . length === 0 ) {
@@ -604,12 +614,16 @@ export default class ScrollableTerminal extends React.PureComponent<Props, State
604
614
605
615
/** remove the block at the given index */
606
616
private willRemoveBlock ( uuid : string , idx : number ) {
607
- this . splice ( uuid , curState => ( {
608
- blocks : curState . blocks
609
- . slice ( 0 , idx )
610
- . concat ( curState . blocks . slice ( idx + 1 ) )
611
- . concat ( curState . blocks . find ( _ => isActive ( _ ) ) ? [ ] : [ Active ( ) ] ) // plus a new block, if needed
612
- } ) )
617
+ this . splice ( uuid , curState => {
618
+ this . removeWatchableBlock ( curState . blocks [ idx ] )
619
+
620
+ return {
621
+ blocks : curState . blocks
622
+ . slice ( 0 , idx )
623
+ . concat ( curState . blocks . slice ( idx + 1 ) )
624
+ . concat ( curState . blocks . find ( _ => isActive ( _ ) ) ? [ ] : [ Active ( ) ] ) // plus a new block, if needed
625
+ }
626
+ } )
613
627
}
614
628
615
629
private tabRefFor ( scrollback : ScrollbackState , ref : HTMLElement ) {
0 commit comments