Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Not specifying callback can result in unhandled error #445

bergman opened this Issue · 1 comment

2 participants


I'm using the convenience methods for making a request without specifying a callback. If that request fails for some reason it will throw an unhandled error. I'm not really interested in whether the request makes it or not in this particular case (hence the missing callback) but the unhandled error exits my process. Just adding a callback or even doing request('http://localhost:1/').on('error', function() {}); works but I would expect the library to handle any errors when using a convenience method. Perhaps this should be noted in the documentation somewhere?

Example code that triggers the error (make sure you're not running anything on port 1!).

var request = require('request');

        throw arguments[1]; // Unhandled 'error' event
Error: connect ECONNREFUSED
    at errnoException (net.js:770:11)
    at Object.afterConnect [as oncomplete] (net.js:761:19)

yes, if you don't pass a callback or add an error listener there is nothing to do on error but throw.

@mikeal mikeal closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.