@@ -79,6 +79,10 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
79
79
80
80
liveSyncProcessInfo . deviceDescriptors = [ ] ;
81
81
82
+ if ( liveSyncProcessInfo . syncToPreviewApp ) {
83
+ await this . $previewAppLiveSyncService . stopLiveSync ( ) ;
84
+ }
85
+
82
86
// Kill typescript watcher
83
87
const projectData = this . $projectDataService . getProjectData ( projectDir ) ;
84
88
await this . $hooksService . executeAfterHooks ( 'watch' , {
@@ -350,6 +354,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
350
354
this . liveSyncProcessesInfo [ projectDir ] . actionsChain = this . liveSyncProcessesInfo [ projectDir ] . actionsChain || Promise . resolve ( ) ;
351
355
this . liveSyncProcessesInfo [ projectDir ] . currentSyncAction = this . liveSyncProcessesInfo [ projectDir ] . actionsChain ;
352
356
this . liveSyncProcessesInfo [ projectDir ] . isStopped = false ;
357
+ this . liveSyncProcessesInfo [ projectDir ] . syncToPreviewApp = liveSyncData . syncToPreviewApp ;
353
358
354
359
const currentDeviceDescriptors = this . getLiveSyncDeviceDescriptors ( projectDir ) ;
355
360
this . liveSyncProcessesInfo [ projectDir ] . deviceDescriptors = _ . uniqBy ( currentDeviceDescriptors . concat ( deviceDescriptors ) , deviceDescriptorPrimaryKey ) ;
@@ -744,13 +749,6 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
744
749
this . liveSyncProcessesInfo [ liveSyncData . projectDir ] . timer = timeoutTimer ;
745
750
746
751
this . $processService . attachToProcessExitSignals ( this , ( ) => {
747
- if ( liveSyncData . syncToPreviewApp ) {
748
- // Do not await here, we are in process exit's handler.
749
- /* tslint:disable:no-floating-promises */
750
- this . $previewAppLiveSyncService . stopLiveSync ( ) ;
751
- /* tslint:enable:no-floating-promises */
752
- }
753
-
754
752
_ . keys ( this . liveSyncProcessesInfo ) . forEach ( projectDir => {
755
753
// Do not await here, we are in process exit's handler.
756
754
/* tslint:disable:no-floating-promises */
@@ -768,7 +766,9 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
768
766
769
767
for ( const projectDir in this . liveSyncProcessesInfo ) {
770
768
try {
771
- await this . stopLiveSync ( projectDir , [ device . deviceInfo . identifier ] ) ;
769
+ if ( _ . find ( this . liveSyncProcessesInfo [ projectDir ] . deviceDescriptors , d => d . identifier === device . deviceInfo . identifier ) ) {
770
+ await this . stopLiveSync ( projectDir , [ device . deviceInfo . identifier ] ) ;
771
+ }
772
772
} catch ( err ) {
773
773
this . $logger . warn ( `Unable to stop LiveSync operation for ${ device . deviceInfo . identifier } .` , err ) ;
774
774
}
0 commit comments