Skip to content

Commit 02216b0

Browse files
committed
fix: force refresh with socket when debugging the application
Currently there is an issue when livesyncing the application when it is stopped on breakpoint. The problem is that the application is always restarted - most probably due to issue with "RefreshRequest" notification. However, this notification was added as we needed to support syncing on wifi devices. As debug command doesn't work with wifi devices, we'll force refresh with socket on debug command. Rel to: #4966
1 parent 3815b74 commit 02216b0

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

lib/controllers/run-controller.ts

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export class RunController extends EventEmitter implements IRunController {
166166
const debugOptions = deviceDescriptor.debugOptions || {};
167167

168168
liveSyncResultInfo.waitForDebugger = !!debugOptions.debugBrk;
169+
liveSyncResultInfo.forceRefreshWithSocket = true;
169170

170171
const refreshInfo = await this.refreshApplicationWithoutDebug(projectData, liveSyncResultInfo, filesChangeEventData, deviceDescriptor, { shouldSkipEmitLiveSyncNotification: true, shouldCheckDeveloperDiscImage: true });
171172

lib/definitions/livesync.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ declare global {
220220
isFullSync: boolean;
221221
waitForDebugger?: boolean;
222222
deviceAppData: Mobile.IDeviceAppData;
223-
didRecover?: boolean
223+
didRecover?: boolean;
224+
forceRefreshWithSocket?: boolean;
224225
}
225226

226227
interface IAndroidLiveSyncResultInfo extends ILiveSyncResultInfo, IAndroidLivesyncSyncOperationResult { }

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
2323
super(platformsDataService, device);
2424
}
2525

26-
private canRefreshWithNotification(projectData: IProjectData): boolean {
26+
private canRefreshWithNotification(projectData: IProjectData, liveSyncInfo?: ILiveSyncResultInfo): boolean {
27+
if (liveSyncInfo && liveSyncInfo.forceRefreshWithSocket) {
28+
return false;
29+
}
30+
2731
if (this.device.isEmulator) {
2832
return false;
2933
}
@@ -72,7 +76,7 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
7276
shouldRestart = true;
7377
} else {
7478
const canExecuteFastSync = this.canExecuteFastSyncForPaths(liveSyncInfo, localToDevicePaths, projectData, deviceAppData.platform);
75-
const isRefreshConnectionSetup = this.canRefreshWithNotification(projectData) || (!this.device.isOnlyWiFiConnected && await this.setupSocketIfNeeded(projectData));
79+
const isRefreshConnectionSetup = this.canRefreshWithNotification(projectData, liveSyncInfo) || (!this.device.isOnlyWiFiConnected && await this.setupSocketIfNeeded(projectData));
7680
if (!canExecuteFastSync || !isRefreshConnectionSetup) {
7781
shouldRestart = true;
7882
}
@@ -93,7 +97,7 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
9397

9498
try {
9599
if (otherFiles.length) {
96-
didRefresh = await this.refreshApplicationCore(projectData);
100+
didRefresh = await this.refreshApplicationCore(projectData, liveSyncInfo);
97101
}
98102
} catch (e) {
99103
didRefresh = false;
@@ -102,9 +106,9 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
102106
return didRefresh;
103107
}
104108

105-
private async refreshApplicationCore(projectData: IProjectData) {
109+
private async refreshApplicationCore(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo) {
106110
let didRefresh = true;
107-
if (this.canRefreshWithNotification(projectData)) {
111+
if (this.canRefreshWithNotification(projectData, liveSyncInfo)) {
108112
didRefresh = await this.refreshWithNotification(projectData);
109113
} else {
110114
if (await this.setupSocketIfNeeded(projectData)) {

0 commit comments

Comments
 (0)