Skip to content

Commit 4bd9408

Browse files
committed
fix: close the inspector app on Inspector proxy close in order to create a new one for the next proxy
1 parent 3f0ea54 commit 4bd9408

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,30 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe
178178
const existingTcpProxy = this.$appDebugSocketProxyFactory.getTCPSocketProxy(this.deviceIdentifier, debugData.applicationIdentifier);
179179
const tcpSocketProxy = existingTcpProxy || await this.$appDebugSocketProxyFactory.addTCPSocketProxy(this.device, debugData.applicationIdentifier);
180180
if (!existingTcpProxy) {
181-
await this.openAppInspector(tcpSocketProxy.address(), debugData, debugOptions);
181+
const inspectorProcess = await this.openAppInspector(tcpSocketProxy.address(), debugData, debugOptions);
182+
if (inspectorProcess) {
183+
tcpSocketProxy.on("close", async () => {
184+
await this.killProcess(inspectorProcess);
185+
});
186+
}
182187
}
183188

184189
return null;
185190
}
186191

187-
private async openAppInspector(fileDescriptor: string, debugData: IDebugData, debugOptions: IDebugOptions): Promise<void> {
192+
private async openAppInspector(fileDescriptor: string, debugData: IDebugData, debugOptions: IDebugOptions): Promise<ChildProcess> {
188193
if (debugOptions.client) {
189194
const inspectorPath = await this.$packageInstallationManager.getInspectorFromCache(inspectorNpmPackageName, debugData.projectDir);
190195

191196
const inspectorSourceLocation = path.join(inspectorPath, inspectorUiDir, "Main.html");
192-
const inspectorApplicationPath = path.join(inspectorPath, inspectorAppName);
197+
const inspectorApplicationPath = path.join(inspectorPath, inspectorAppName, "Contents", "MacOS", inspectorAppName, "Contents", "MacOS", "NativeScript Inspector");
193198

194-
const cmd = `open -a '${inspectorApplicationPath}' --args '${inspectorSourceLocation}' '${debugData.projectName}' '${fileDescriptor}'`;
195-
await this.$childProcess.exec(cmd);
199+
const inspectorProcess: ChildProcess = this.$childProcess.spawn(inspectorApplicationPath, [inspectorSourceLocation, debugData.projectName, fileDescriptor]);
200+
inspectorProcess.on("error", (e: Error) => this.$logger.trace(e));
201+
return inspectorProcess;
196202
} else {
197203
this.$logger.info("Suppressing debugging client.");
204+
return null;
198205
}
199206
}
200207
}

0 commit comments

Comments
 (0)