Skip to content

Commit 7605f81

Browse files
authored
don't restart application twice on crash (#3051)
1 parent 815f0a9 commit 7605f81

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/services/livesync/android-device-livesync-service.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl
3636
`${deviceProjectRootDirname}/sync`]
3737
);
3838

39-
await this.reloadResources(deviceAppData, localToDevicePaths);
39+
const reloadedSuccessfully = await this.reloadApplicationFiles(deviceAppData, localToDevicePaths);
4040

41-
const canExecuteFastSync = !liveSyncInfo.isFullSync && !_.some(localToDevicePaths,
41+
const canExecuteFastSync = reloadedSuccessfully && !liveSyncInfo.isFullSync && !_.some(localToDevicePaths,
4242
(localToDevicePath: Mobile.ILocalToDevicePathData) => !this.canExecuteFastSync(localToDevicePath.getLocalPath(), projectData, this.device.deviceInfo.platform));
4343

4444
if (!canExecuteFastSync) {
@@ -84,14 +84,15 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl
8484
await this.cleanLivesyncDirectories(deviceAppData);
8585
}
8686

87-
private async reloadResources(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise<void> {
87+
private async reloadApplicationFiles(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise<boolean> {
8888
await this.device.adb.executeCommand(["forward", `tcp:${AndroidDeviceLiveSyncService.BACKEND_PORT.toString()}`, `localabstract:${deviceAppData.appIdentifier}-livesync`]);
8989

90-
if (await this.sendPageReloadMessage()) {
90+
if (await this.awaitRuntimeReloadSuccessMessage()) {
9191
await this.cleanLivesyncDirectories(deviceAppData);
9292
} else {
93-
await this.restartApplication(deviceAppData); //in case runtime socket error/close
93+
return false;
9494
}
95+
return true;
9596
}
9697

9798
public async removeFiles(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): Promise<void> {
@@ -115,7 +116,7 @@ export class AndroidDeviceLiveSyncService extends DeviceLiveSyncServiceBase impl
115116
return this.$injector.resolve(AndroidDeviceHashService, { adb, appIdentifier });
116117
}
117118

118-
private async sendPageReloadMessage(): Promise<boolean> {
119+
private async awaitRuntimeReloadSuccessMessage(): Promise<boolean> {
119120
return new Promise<boolean>((resolve, reject) => {
120121
let isResolved = false;
121122
let socket = new net.Socket();

0 commit comments

Comments
 (0)