mafintosh / mafintosh/dns-socket
socket.bind() with bogus or unavailable address fails silently
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 106
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Calling socket.bind with a bogus or unavailable address causes the process to fail silently. Example:
'use strict';
const dnsSocket = require('.')
const socket = dnsSocket({retries: 0, timeout: 5000});
new Promise(function (fulfill, reject){
socket.on('error', reject);
try{
socket.bind(null, '8.8.8.8', fulfill);
}
catch(e){
return reject(e);
}
})
.then(function(){
console.log('socket bound');
socket.destroy();
})
.catch(function(err){
console.log('caught error', err);
});
When I run this with Node 6, there is no output, no errors caught, and the script exits prematurely. Looks like dns-socket emits a 'warning' instead of an 'error' in this case.
PR incoming.
Edit: just my $.02: I think this function in index.js should not try to pick/choose which errors constitute emitting a warning vs. an error, but should always emit an error instead:
function onerror (err) {
if (err.code === 'EACCES' || err.code === 'EADDRINUSE') {
self.emit('error', err)
} else {
self.emit('warning', err)
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in index.js at the onerror function shown in the issue and reproduce the problem with the provided Node.js example. Done means binding to a bogus or unavailable address produces observable error output and reaches the example's catch handler instead of exiting silently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100