Skip to content

Commit 647ad0b

Browse files
Fix livesync for iOS
CLI is destroying the socket too early and so the runtime cannot handle the message that we've sent. As a result livesync is not working sometimes. When we sent message, the socket will always receive data as result. If it's error, the result will contain it. In any case, we should destroy the socket when data is received.
1 parent b5897c4 commit 647ad0b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/services/livesync/ios-livesync-service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class IOSLiveSyncService extends liveSyncServiceBaseLib.LiveSyncServiceBase<Mobi
1414
private $iOSSocketRequestExecutor: IiOSSocketRequestExecutor,
1515
private $iOSNotification: IiOSNotification,
1616
private $iOSEmulatorServices: Mobile.IiOSSimulatorService,
17-
private $injector: IInjector) {
17+
private $injector: IInjector,
18+
private $logger: ILogger) {
1819
super(_device);
1920
}
2021

@@ -45,7 +46,12 @@ class IOSLiveSyncService extends liveSyncServiceBaseLib.LiveSyncServiceBase<Mobi
4546
private sendPageReloadMessage(socket: net.Socket): void {
4647
try {
4748
this.sendPageReloadMessageCore(socket);
48-
} finally {
49+
socket.once("data", (data: NodeBuffer|string) => {
50+
this.$logger.trace(`Socket sent data: ${data.toString()}`);
51+
socket.destroy();
52+
});
53+
} catch(err) {
54+
this.$logger.trace("Error while sending page reload:", err);
4955
socket.destroy();
5056
}
5157
}

0 commit comments

Comments
 (0)