Skip to content

Commit 7c8ebc7

Browse files
committed
removed mutiple hand shake error events
1 parent 86492c1 commit 7c8ebc7

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

lib/commands/client_handshake.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ ClientHandshake.prototype.calculateNativePasswordAuthToken = function (authPlugi
6868
ClientHandshake.prototype.handshakeInit = function (helloPacket, connection) {
6969
var command = this;
7070

71-
this.on('error', function (err) {
72-
connection._protocolError = err;
73-
connection.emit('error', err);
71+
this.on('error', function (e) {
72+
connection._protocolError = e;
7473
});
74+
7575
this.handshake = Packets.Handshake.fromPacket(helloPacket);
7676
if (connection.config.debug) {
7777
console.log('Server hello packet: capability flags:%d=(%s)', this.handshake.capabilityFlags,

lib/connection.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,17 @@ function Connection (opts)
103103
return;
104104
}
105105

106-
// TODO: move to protocolError()
107106
if (!connection._protocolError) { // no particular error message before disconnect
108-
connection._protocolError = 'PROTOCOL_CONNECTION_LOST';
107+
connection._protocolError = new Error('Connection lost: The server closed the connection.');
108+
connection._protocolError.fatal = true;
109+
connection._protocolError.code = 'PROTOCOL_CONNECTION_LOST';
109110
}
110-
var err = new Error('Connection lost: The server closed the connection.');
111-
err.fatal = true;
112-
err.code = connection._protocolError;
113-
connection._notifyError(err);
111+
112+
connection._notifyError(connection._protocolError);
114113
});
115114
var handshakeCommand;
116115
if (!this.config.isServer) {
117116
handshakeCommand = new Commands.ClientHandshake(this.config.clientFlags);
118-
handshakeCommand.on('error', function (e) { connection.emit('error', e); });
119117
handshakeCommand.on('end', function () {
120118
connection._handshakePacket = handshakeCommand.handshake;
121119
connection.threadId = handshakeCommand.handshake.connectionId;

0 commit comments

Comments
 (0)