node-dns icon indicating copy to clipboard operation
node-dns copied to clipboard

Unhandled 'error' event in pending.js

Open mingshun opened this issue 11 years ago • 6 comments

events.js:71
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: getHostByName ETIMEOUT
    at SocketQueue._onclose (/root/ropi/node_modules/native-dns/lib/pending.js:201:9)
    at EventEmitter.emit (events.js:93:17)
    at Socket.TCPSocket.bind (/root/ropi/node_modules/native-dns/lib/utils.js:132:12)
    at Socket.EventEmitter.emit (events.js:96:17)
    at Socket._destroy.destroyed (net.js:358:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

When using dns request in tcp protocol, timeout causes this. It made the whole app crashed. The exception caused from pending.js. Did I forget to catch the error or is the bug of node-dns?

mingshun avatar Mar 10 '13 03:03 mingshun

what steps do I need to reproduce this?

tjfontaine avatar Mar 10 '13 16:03 tjfontaine

I don't know how to reproduce it because the exception didn't specified which line of my code causes this exception. I use Request to look up domains in my app. There is a domain list in the app. For domains within the list, the app would look up them in tcp protocol, others in udp protocol. This exception seems to be thrown when the udp dns request had come to timeout, then another tcp dns request began to establish. And there is another exception would occur when tcp dns request times out before udp dns request established:

/root/ropi/node_modules/native-dns/lib/pending.js:166
 if (this._socket.unref) {
 ^
 TypeError: Cannot read property 'unref' of undefined
 at SocketQueue._unref (/root/ropi/node_modules/native-dns/lib/pending.js:166:21)
 at SocketQueue._onlisten (/root/ropi/node_modules/native-dns/lib/pending.js:189:8)
 at EventEmitter.emit (events.js:93:17)
 at Socket.TCPSocket.bind._socket.on.self.bound (/root/ropi/node_modules/native-dns/lib/utils.js:122:12)
 at Socket.EventEmitter.emit (events.js:93:17)
 at Object.afterConnect [as oncomplete] (net.js:752:10)

mingshun avatar Mar 11 '13 09:03 mingshun

Hi, I am also getting this error ocassionaly:

2013-03-12T12:18:34.099Z - error: TypeError: Cannot read property 'unref' of undefined
    at SocketQueue._unref (node_modules/native-dns/lib/pending.js:166:21)
    at SocketQueue._onmessage (node_modules/native-dns/lib/pending.js:158:8)
    at EventEmitter.emit (events.js:99:17)
    at Socket.TCPSocket.catchMessages node_modules/native-dns/lib/utils.js:154:14)
    at Socket.EventEmitter.emit (events.js:96:17)
    at TCP.onread (net.js:396:14)

Unfortunatelly I could not find out when it occurs exactly. I am only using these two methods: dns.resolve4 and dns.reverse

Any suggestions how to workaround this for now?

Thanks

VilemP avatar Mar 12 '13 12:03 VilemP

I'm going to be investigating this today, sorry for the late response

tjfontaine avatar Mar 23 '13 16:03 tjfontaine

Looks like it assumes the socket still exists when in fact it was already destroyed. I changed line 166 to get past the errors for now. if (this._socket && this._socket.unref) {

Looking forward the real fix though.

NodePing avatar Mar 23 '13 16:03 NodePing

Looks like a very old issue but I had the same issue today with same call stack as https://github.com/tjfontaine/node-dns/issues/43#issuecomment-14704655

native-dns: 0.7.0 node: 4.1.1

gramakri avatar Feb 03 '16 17:02 gramakri