diff --git a/lib/portfinder.js b/lib/portfinder.js index ac6f638..2bc65e2 100644 --- a/lib/portfinder.js +++ b/lib/portfinder.js @@ -38,9 +38,9 @@ internals.testPort = function(options, callback) { function onListen () { debugTestPort("done w/ testPort(): OK", options.host, "port", options.port); - options.server.removeListener('error', onError); - options.server.close(); - callback(null, options.port); + options.server.removeListener('error', onError); + options.server.close(); + callback(null, options.port); } function onError (err) {