diff --git a/lib/tcp/index.js b/lib/tcp/index.js index 1f376c4..4aae343 100644 --- a/lib/tcp/index.js +++ b/lib/tcp/index.js @@ -155,11 +155,12 @@ module.exports.create = function (deps, config) { conn.once('error', onError); conn.once('data', function (chunk) { //Adding this to track problems with error handling TODO: Remove this error handler. - conn.on('error', function(err) { + conn.once('error', function(err) { console.log("Received error in tcpHandler after removing error listener.", - "Number of errorListeners:", - conn.listenerCount() + "Number of errorListeners:", conn.listenerCount("error"), + "Error: ", err ); + if(!conn.listenerCount("error")) conn.emit("error", err); }); conn.removeListener('error', onError); peek(conn, chunk, opts);