tjfontaine / node-dns

Replacement dns module in pure javascript for node.js
MIT License
585 stars 154 forks source link

Please add this._socket.on('error') in TCPSocket.prototype.bind #97

Open kupson opened 9 years ago

kupson commented 9 years ago

Hi,

Please consider adding error listener/emitter on TCP sockets. Right now I'm getting errors like below:

2015-06-30_16:14:17.57533 events.js:85
2015-06-30_16:14:17.57541       throw er; // Unhandled 'error' event
2015-06-30_16:14:17.57542             ^
2015-06-30_16:14:17.57544 Error: connect ETIMEDOUT
2015-06-30_16:14:17.57545     at exports._errnoException (util.js:746:11)
2015-06-30_16:14:17.57546     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)

As a quick workaround I monkey-patched TCPSocket:

var native_dns_utils = require('native-dns/lib/utils');
native_dns_utils.TCPSocket.prototype._monkey_catchMessages = native_dns_utils.TCPSocket.prototype.catchMessages;
native_dns_utils.TCPSocket.prototype.catchMessages = function () {
    var self = this;
    this._socket.on('error', function(err) {
        self.bound = false;
        self.emit('close', err);
    });
    this._monkey_catchMessages();
};

Kind Regards, Rafal Kupka

panta82 commented 8 years ago

I just got stung by this. Causes hard to debug crashes of the entire application. Not cool.

nebulade commented 8 years ago

Hit the same issue, looks like this module is not maintained anymore.