Skip to content

Commit 17107f4

Browse files
authored
Merge pull request #149 from Pwndrian/resolve-on-close
Wait until server is closed before invoking callback
2 parents 123a06f + 09132c3 commit 17107f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/portfinder.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ internals.testPort = function(options, callback) {
3939
debugTestPort("done w/ testPort(): OK", options.host, "port", options.port);
4040

4141
options.server.removeListener('error', onError);
42-
options.server.close();
43-
callback(null, options.port);
42+
options.server.close(function () {
43+
debugTestPort("done w/ testPort(): Server closed", options.host, "port", options.port);
44+
callback(null, options.port);
45+
});
4446
}
4547

4648
function onError (err) {

0 commit comments

Comments
 (0)