From a42f0437681f90ea232a866736fed1406f1a2a89 Mon Sep 17 00:00:00 2001 From: Ian Scott Date: Fri, 13 May 2016 18:26:40 -0700 Subject: [PATCH] Emit error when handshake fails, such as with bad xauth --- lib/handshake.js | 2 +- lib/xcore.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/handshake.js b/lib/handshake.js index 9fbb623..254837b 100644 --- a/lib/handshake.js +++ b/lib/handshake.js @@ -90,7 +90,7 @@ function readScreens(bl, display, cbDisplayReady) if (display.screen.length == display.screen_num) { delete display.screen_num; - cbDisplayReady(display); + cbDisplayReady(null, display); return; } else { readScreens(bl, display, cbDisplayReady); diff --git a/lib/xcore.js b/lib/xcore.js index 5c68b1c..519c665 100644 --- a/lib/xcore.js +++ b/lib/xcore.js @@ -531,10 +531,12 @@ XClient.prototype.startHandshake = function() { var client = this; handshake.writeClientHello(this.pack_stream, this.displayNum, this.authHost, this.authFamily); - handshake.readServerHello(this.pack_stream, function(display) + handshake.readServerHello(this.pack_stream, function(err, display) { - // TODO: readServerHello can set error state in display - // emit error in that case + if (err) { + client.emit('error', err); + return; + } client.expectReplyHeader(); client.display = display; display.client = client;