Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Omitting callback may throw uncaught exception #39

Open
strk opened this issue Mar 5, 2014 · 5 comments
Open

Omitting callback may throw uncaught exception #39

strk opened this issue Mar 5, 2014 · 5 comments
Assignees

Comments

@strk
Copy link

strk commented Mar 5, 2014

When not passing a callback to the sending functions (any), DNS errors would result in an exception being thrown like this:

events.js:66
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: getaddrinfo EADDRINFO
    at errnoException (dns.js:31:11)
    at Object.onanswer [as oncomplete] (dns.js:123:16)

See CartoDB/Windshaft-cartodb#180

@strk
Copy link
Author

strk commented Mar 5, 2014

It looks like the way to fix this would be to install a listener for "error" on this.socket

@strk
Copy link
Author

strk commented Mar 5, 2014

I confirm it works by installing an handler, and it can be done from the outside:

client = new StatsD();
client.socket.on('error', function(err) { console.log(err); });

I don't know if it'd make sense for this module to provide a default handler...

@devdazed
Copy link
Collaborator

devdazed commented Mar 5, 2014

hmm, I don't think it should just be "handled" the only thing that would make sense would be to make StatsD an emitter and bubble the error emission up. Although the only problem this solves is the forced breakage of the law of demeter.

@strk
Copy link
Author

strk commented Mar 5, 2014

I agree it should bubble up. It would also be nice to integrate the documentation in that case.
Actually I do see that the current documentation told me about handling the error:
https://github.com/sivy/node-statsd#errors

@devdazed
Copy link
Collaborator

devdazed commented Mar 5, 2014

yeah, it's bad API design on my part for forcing the breakage of LoD ... and then blatantly documenting it. heh. If I have some time in the next week or so, I'll get this in.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants