You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you socket.bind() to a local address, and then the interface becomes unavailable (ie. network goes down, network interface no longer available, cable unplugged, etc), and you then run a query, the query will hang indefinitely.
Example:
'use strict';
const dnsSocket = require('.')
const socket = dnsSocket({retries: 0, timeout: 5000});
// bind to some local address, 192.168.0.2 in this case, adjust accordingly
new Promise(function (fulfill, reject){
socket.on('error', reject);
socket.on('listening', fulfill);
socket.bind(null, '192.168.0.2');
})
// do something like unplug your network cable
// to make the bound address --> EADDRNOTAVAIL
.then(function(){
console.log('socket bound');
console.log('to reproduce, kill your network connection within the next 5 seconds');
return new Promise(function(resolve, reject) {
setTimeout(resolve, 5000);
});
})
// make a query, it'll hang indefinitely
.then(function(){
console.log('making socket query, should hang indefinitely');
return new Promise(function(resolve, reject) {
socket.query({
questions: [{
type: 'A',
name: 'google.com'
}]
},
53,
'1.1.1.1',
function(err, res){
if (err) return reject(err);
resolve(res);
}
);
});
})
.then(function(res){
console.log('got response', res);
console.log('all done, destroy socket');
socket.destroy();
})
.catch(function(err){
console.log('caught error', err);
socket.destroy();
});
Output:
socket bound
to reproduce, kill your network connection within the next 5 seconds
making socket query, should hang indefinitely
To reproduce, you'll need to:
replace '192.168.0.2' with your local IP address
unplug your network cable/kill your network connection when prompted
I think I see the issue, PR incoming.
The text was updated successfully, but these errors were encountered:
Nevermind this issue, it can probably be closed :) I didn't wait long enough. dns-socket was still doing retries under the hood and it did eventually time out, even though I did specify 0 retries, 0 is falsey, and thus in the options will still default to 5, i.e:
Option parsing should be improved to support a 0 value on numeric values. Not sure I agree with immediately failing on socket.send, some errors should be retried, some not, but it's not really easy to distinguish. I'd rather walk on the safe side and retry always.
BTW thanks for this module.
If you
socket.bind()
to a local address, and then the interface becomes unavailable (ie. network goes down, network interface no longer available, cable unplugged, etc), and you then run a query, the query will hang indefinitely.Example:
Output:
To reproduce, you'll need to:
I think I see the issue, PR incoming.
The text was updated successfully, but these errors were encountered: