diff --git a/lib/common b/lib/common index 70ba4ca1ac..9623764190 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit 70ba4ca1ac271b52c2cafbb4fbdbfb66a00744ed +Subproject commit 9623764190f3d7e1e64add933d9c31cb2148704d diff --git a/lib/device-sockets/ios/socket-proxy-factory.ts b/lib/device-sockets/ios/socket-proxy-factory.ts index 87eb3390ae..86215b9e05 100644 --- a/lib/device-sockets/ios/socket-proxy-factory.ts +++ b/lib/device-sockets/ios/socket-proxy-factory.ts @@ -90,7 +90,7 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact this.$logger.info("Frontend client connected."); let _socket; try { - _socket = await factory(); + _socket = await helpers.connectEventuallyUntilTimeout(factory, 10000); } catch (err) { err.deviceIdentifier = deviceIdentifier; this.$logger.trace(err); diff --git a/lib/services/ios-debug-service.ts b/lib/services/ios-debug-service.ts index 446698b477..86ab0644e3 100644 --- a/lib/services/ios-debug-service.ts +++ b/lib/services/ios-debug-service.ts @@ -231,14 +231,23 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS } private getSocketFactory(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): () => Promise { + let pendingExecution: Promise = null; const factory = async () => { - const port = await this.$iOSDebuggerPortService.getPort({ projectDir: debugData.projectDir, deviceId: debugData.deviceIdentifier, appId: debugData.applicationIdentifier }, debugOptions); - if (!port) { - this.$errors.fail("NativeScript debugger was not able to get inspector socket port."); + if (!pendingExecution) { + const func = async () => { + const port = await this.$iOSDebuggerPortService.getPort({ projectDir: debugData.projectDir, deviceId: debugData.deviceIdentifier, appId: debugData.applicationIdentifier }, debugOptions); + if (!port) { + this.$errors.fail("NativeScript debugger was not able to get inspector socket port."); + } + const socket = device ? await device.connectToPort(port) : net.connect(port); + this._sockets.push(socket); + pendingExecution = null; + return socket; + }; + pendingExecution = func(); } - const socket = device ? await device.connectToPort(port) : await this.$iOSEmulatorServices.connectToPort({ port }); - this._sockets.push(socket); - return socket; + + return pendingExecution; }; factory.bind(this);