Skip to content

Commit 5c269fb

Browse files
committed
fix(cli): race condition when getting iOS inspector port
Closes NativeScript#3701
1 parent 0be8aca commit 5c269fb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/common/mobile/ios/simulator/ios-simulator-device.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,21 @@ export class IOSSimulator extends IOSDeviceBase implements Mobile.IiOSDevice {
8787
attachRequestMessage,
8888
this.deviceInfo.identifier
8989
);
90-
const port = await super.getDebuggerPort(appId);
90+
91+
// Retry posting the notification every five seconds, in case the AttachRequest
92+
// event handler wasn't registered when the first one was sent
93+
const postNotificationRetryInterval = setInterval(() => {
94+
this.$iOSEmulatorServices
95+
.postDarwinNotification(
96+
attachRequestMessage,
97+
this.deviceInfo.identifier
98+
)
99+
.catch((e) => this.$logger.error(e));
100+
}, 5e3);
101+
102+
const port = await super.getDebuggerPort(appId).finally(() => {
103+
clearInterval(postNotificationRetryInterval);
104+
});
91105
try {
92106
socket = await helpers.connectEventuallyUntilTimeout(async () => {
93107
return this.$iOSEmulatorServices.connectToPort({ port });

0 commit comments

Comments
 (0)