@@ -79,6 +79,10 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
7979
8080 liveSyncProcessInfo . deviceDescriptors = [ ] ;
8181
82+ if ( liveSyncProcessInfo . syncToPreviewApp ) {
83+ await this . $previewAppLiveSyncService . stopLiveSync ( ) ;
84+ }
85+
8286 // Kill typescript watcher
8387 const projectData = this . $projectDataService . getProjectData ( projectDir ) ;
8488 await this . $hooksService . executeAfterHooks ( 'watch' , {
@@ -350,6 +354,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
350354 this . liveSyncProcessesInfo [ projectDir ] . actionsChain = this . liveSyncProcessesInfo [ projectDir ] . actionsChain || Promise . resolve ( ) ;
351355 this . liveSyncProcessesInfo [ projectDir ] . currentSyncAction = this . liveSyncProcessesInfo [ projectDir ] . actionsChain ;
352356 this . liveSyncProcessesInfo [ projectDir ] . isStopped = false ;
357+ this . liveSyncProcessesInfo [ projectDir ] . syncToPreviewApp = liveSyncData . syncToPreviewApp ;
353358
354359 const currentDeviceDescriptors = this . getLiveSyncDeviceDescriptors ( projectDir ) ;
355360 this . liveSyncProcessesInfo [ projectDir ] . deviceDescriptors = _ . uniqBy ( currentDeviceDescriptors . concat ( deviceDescriptors ) , deviceDescriptorPrimaryKey ) ;
@@ -744,13 +749,6 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
744749 this . liveSyncProcessesInfo [ liveSyncData . projectDir ] . timer = timeoutTimer ;
745750
746751 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-
754752 _ . keys ( this . liveSyncProcessesInfo ) . forEach ( projectDir => {
755753 // Do not await here, we are in process exit's handler.
756754 /* tslint:disable:no-floating-promises */
@@ -768,7 +766,9 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
768766
769767 for ( const projectDir in this . liveSyncProcessesInfo ) {
770768 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+ }
772772 } catch ( err ) {
773773 this . $logger . warn ( `Unable to stop LiveSync operation for ${ device . deviceInfo . identifier } .` , err ) ;
774774 }
0 commit comments