Skip to content

Commit d97f6dc

Browse files
author
Fatme
authored
Merge pull request #3842 from NativeScript/fatme/fix-inspector
Fix `tns debug ios --inspector`
2 parents c2d261a + d15fb00 commit d97f6dc

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

lib/device-sockets/ios/socket-proxy-factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact
9090
this.$logger.info("Frontend client connected.");
9191
let _socket;
9292
try {
93-
_socket = await factory();
93+
_socket = await helpers.connectEventuallyUntilTimeout(factory, 10000);
9494
} catch (err) {
9595
err.deviceIdentifier = deviceIdentifier;
9696
this.$logger.trace(err);

lib/services/ios-debug-service.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,23 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
231231
}
232232

233233
private getSocketFactory(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): () => Promise<net.Socket> {
234+
let pendingExecution: Promise<net.Socket> = null;
234235
const factory = async () => {
235-
const port = await this.$iOSDebuggerPortService.getPort({ projectDir: debugData.projectDir, deviceId: debugData.deviceIdentifier, appId: debugData.applicationIdentifier }, debugOptions);
236-
if (!port) {
237-
this.$errors.fail("NativeScript debugger was not able to get inspector socket port.");
236+
if (!pendingExecution) {
237+
const func = async () => {
238+
const port = await this.$iOSDebuggerPortService.getPort({ projectDir: debugData.projectDir, deviceId: debugData.deviceIdentifier, appId: debugData.applicationIdentifier }, debugOptions);
239+
if (!port) {
240+
this.$errors.fail("NativeScript debugger was not able to get inspector socket port.");
241+
}
242+
const socket = device ? await device.connectToPort(port) : net.connect(port);
243+
this._sockets.push(socket);
244+
pendingExecution = null;
245+
return socket;
246+
};
247+
pendingExecution = func();
238248
}
239-
const socket = device ? await device.connectToPort(port) : await this.$iOSEmulatorServices.connectToPort({ port });
240-
this._sockets.push(socket);
241-
return socket;
249+
250+
return pendingExecution;
242251
};
243252

244253
factory.bind(this);

0 commit comments

Comments
 (0)