Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/protocol/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ Connection.prototype._addListeners = function _addListeners(socket) {
if (cb) {
self._state.receive = null; // a callback should be called only once
cb(err);
} else {
} else if (self.listeners('error').length) {
self.emit('error', err);
} else {
debug('onerror', err);
}
}
socket.on('error', onerror);
Expand All @@ -239,7 +241,7 @@ Connection.prototype._addListeners = function _addListeners(socket) {
function onend() {
var err = new Error('Connection closed by server');
err.code = 'EHDBCLOSE';
socket.emit('error', err);
onerror(err);
}
socket.on('end', onend);
};
Expand Down
6 changes: 0 additions & 6 deletions lib/protocol/ConnectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ ConnectionManager.prototype._openConnectionMultiDbCase = function _openConnectio
}
}

function onError(err) {
cb(err);
}
conn.on('error', onError);

function handleError(err) {
conn.close();
cb(err);
Expand All @@ -99,7 +94,6 @@ ConnectionManager.prototype._openConnectionMultiDbCase = function _openConnectio
}

if (info.isConnected) {
conn.removeListener('error', onError);
cb(null);
} else {
conn._closeSilently();
Expand Down
6 changes: 3 additions & 3 deletions test/hdb.Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,12 @@ describe('hdb', function () {
databaseName: 'DB0'
});

client._connection.fetchDbConnectInfo = function () {
client._connection.emit('error', new Error('Network error emitted'));
client._connection.fetchDbConnectInfo = function (options, cb) {
cb(new Error('Network error'));
};

client.connect(function (err) {
err.message.should.equal('Could not connect to any host: [ localhost:30013 - Network error emitted ]');
err.message.should.equal('Could not connect to any host: [ localhost:30013 - Network error ]');
done();
});
});
Expand Down