Skip to content

Commit 871b343

Browse files
Merge pull request #4459 from NativeScript/vladimirov/fix-debug-sidekick
fix: raise debuggerAttached only if app is restarted
2 parents a2c64f9 + 464cf5c commit 871b343

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/definitions/livesync.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ interface IPlatformLiveSyncService {
401401
shouldRestart(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<boolean>;
402402
getDeviceLiveSyncService(device: Mobile.IDevice, projectData: IProjectData): INativeScriptDeviceLiveSyncService;
403403
}
404-
interface IRefreshApplicationInfo {
405-
didRefresh: boolean;
404+
interface IRestartApplicationInfo {
405+
didRestart: boolean;
406406
}
407407

408408
interface INativeScriptDeviceLiveSyncService {

lib/services/livesync/livesync-service.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -145,30 +145,30 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
145145
}
146146

147147
@performanceLog()
148-
private async refreshApplication(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string): Promise<IRefreshApplicationInfo | IDebugInformation> {
148+
private async refreshApplication(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string): Promise<IRestartApplicationInfo | IDebugInformation> {
149149
const deviceDescriptor = this.getDeviceDescriptor(liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier, projectData.projectDir);
150150

151151
return deviceDescriptor && deviceDescriptor.debugggingEnabled ?
152152
this.refreshApplicationWithDebug(projectData, liveSyncResultInfo, debugOpts, outputPath) :
153153
this.refreshApplicationWithoutDebug(projectData, liveSyncResultInfo, debugOpts, outputPath);
154154
}
155155

156-
private async refreshApplicationWithoutDebug(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string, settings?: IRefreshApplicationSettings): Promise<IRefreshApplicationInfo> {
157-
const result = { didRefresh: false };
156+
private async refreshApplicationWithoutDebug(projectData: IProjectData, liveSyncResultInfo: ILiveSyncResultInfo, debugOpts?: IDebugOptions, outputPath?: string, settings?: IRefreshApplicationSettings): Promise<IRestartApplicationInfo> {
157+
const result = { didRestart: false };
158158
const platform = liveSyncResultInfo.deviceAppData.platform;
159159
const platformLiveSyncService = this.getLiveSyncService(platform);
160160
const applicationIdentifier = projectData.projectIdentifiers[platform.toLowerCase()];
161161
try {
162162
let shouldRestart = await platformLiveSyncService.shouldRestart(projectData, liveSyncResultInfo);
163163
if (!shouldRestart) {
164-
result.didRefresh = await platformLiveSyncService.tryRefreshApplication(projectData, liveSyncResultInfo);
165-
shouldRestart = !result.didRefresh;
164+
shouldRestart = !await platformLiveSyncService.tryRefreshApplication(projectData, liveSyncResultInfo);
166165
}
167166

168167
if (shouldRestart) {
169168
const deviceIdentifier = liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier;
170169
this.emit(DEBUGGER_DETACHED_EVENT_NAME, { deviceIdentifier });
171170
await platformLiveSyncService.restartApplication(projectData, liveSyncResultInfo);
171+
result.didRestart = true;
172172
}
173173
} catch (err) {
174174
this.$logger.info(`Error while trying to start application ${applicationIdentifier} on device ${liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier}. Error is: ${err.message || err}`);
@@ -212,7 +212,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
212212
// if we try to send the launch request, the debugger port will not be printed and the command will timeout
213213
debugOptions.start = !debugOptions.debugBrk;
214214

215-
debugOptions.forceDebuggerAttachedEvent = !refreshInfo.didRefresh;
215+
debugOptions.forceDebuggerAttachedEvent = refreshInfo.didRestart;
216216
const deviceOption = {
217217
deviceIdentifier: liveSyncResultInfo.deviceAppData.device.deviceInfo.identifier,
218218
debugOptions: debugOptions,

0 commit comments

Comments
 (0)