From bf75573bd99d3b39a21e75f3e8d5c3a6691766a4 Mon Sep 17 00:00:00 2001 From: DimitarTachev Date: Wed, 22 Aug 2018 15:19:40 +0300 Subject: [PATCH] fix: clear the socket timer on timeout (avoid `Cannot set property 'socket' of null` on the next tick) --- lib/services/livesync/android-livesync-tool.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/services/livesync/android-livesync-tool.ts b/lib/services/livesync/android-livesync-tool.ts index 0f319faacb..83054d18c1 100644 --- a/lib/services/livesync/android-livesync-tool.ts +++ b/lib/services/livesync/android-livesync-tool.ts @@ -313,6 +313,10 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool { const connectionTimer = setTimeout(() => { if (!isConnected) { isConnected = true; + if (this.pendingConnectionData && this.pendingConnectionData.socketTimer) { + clearTimeout(this.pendingConnectionData.socketTimer); + } + reject(lastKnownError || new Error("Socket connection timeouted.")); this.pendingConnectionData = null; }