Added error handling work-around to prevent the process from crashing.

This commit is contained in:
John Shaver 2018-05-04 08:43:21 -07:00
parent e462978154
commit 089d85df67
2 changed files with 12 additions and 1 deletions

View File

@ -154,6 +154,13 @@ 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) {
console.log("Received error in tcpHandler after removing error listener.",
"Number of errorListeners:",
conn.listenerCount()
);
});
conn.removeListener('error', onError);
peek(conn, chunk, opts);
});

View File

@ -56,7 +56,11 @@ module.exports.create = function (deps, config, tcpMods) {
socket.on('error', function (err) {
console.log('wrapped TLS socket error', err);
reader.emit('error', err);
if(reader.listenerCount("error")){
reader.emit('error', err);
} else {
console.log('Wrapped TLS socket had no error handlers for error. Socket object: ', reader);
}
});
writer.on('error', function (err) {
console.error('socket-pair writer error', err);