Skip to content

Commit ac8cf2f

Browse files
Fix error handling during fast sync (#2991)
During fast sync we shouldn't clear all listeners handling `error` event. If we do then any error raised is treated as unhandled and leads to a crash.
1 parent 52c88bb commit ac8cf2f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,16 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
139139
payload.writeInt32BE(length, 0);
140140
payload.write(message, 4, length, "utf16le");
141141

142-
this.socket.once("error", (error: Error) => {
142+
const errorCallback = (error: Error) => {
143143
if (!isResolved) {
144144
isResolved = true;
145145
reject(error);
146146
}
147-
});
147+
};
148+
this.socket.once("error", errorCallback);
148149

149150
this.socket.write(payload, "utf16le", () => {
150-
this.socket.removeAllListeners("error");
151+
this.socket.removeListener("error", errorCallback);
151152

152153
if (!isResolved) {
153154
isResolved = true;

0 commit comments

Comments
 (0)