{"action":"opened","issue":{"url":"https://api.github.com/repos/shz/node-mailgun/issues/23","labels_url":"https://api.github.com/repos/shz/node-mailgun/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/shz/node-mailgun/issues/23/comments","events_url":"https://api.github.com/repos/shz/node-mailgun/issues/23/events","html_url":"https://github.com/shz/node-mailgun/issues/23","id":121131294,"number":23,"title":"sendText crashes when dns lookup fails","user":{"login":"henridf","id":1022041,"avatar_url":"https://avatars.githubusercontent.com/u/1022041?v=3","gravatar_id":"","url":"https://api.github.com/users/henridf","html_url":"https://github.com/henridf","followers_url":"https://api.github.com/users/henridf/followers","following_url":"https://api.github.com/users/henridf/following{/other_user}","gists_url":"https://api.github.com/users/henridf/gists{/gist_id}","starred_url":"https://api.github.com/users/henridf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henridf/subscriptions","organizations_url":"https://api.github.com/users/henridf/orgs","repos_url":"https://api.github.com/users/henridf/repos","events_url":"https://api.github.com/users/henridf/events{/privacy}","received_events_url":"https://api.github.com/users/henridf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-09T00:15:38Z","updated_at":"2015-12-09T00:15:38Z","closed_at":null,"body":"The node process crashes on an uncaught error when calling `sendText` when the network is disconnected:\r\n\r\n```\r\nevents.js:141\r\n      throw er; // Unhandled 'error' event\r\n      ^\r\n\r\nError: getaddrinfo ENOTFOUND api.mailgun.net api.mailgun.net:443\r\n    at errnoException (dns.js:26:10)\r\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)\r\n```\r\n\r\nThis is due to the lack of error handler on the https request object. Adding a handler like:\r\n\r\n```\r\nreq.on('error', function(e) {\r\n...\r\n});\r\n```\r\non the request object fixes the issue.\r\n"}}