Skip to content

Commit 09132c3

Browse files
committed
Wait until server is closed before invoking callback
1 parent 123a06f commit 09132c3

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)