Closed sla89 closed 4 years ago
I am also having this issue as I am immediately starting a server to provide SSH tunnel access, and every now and then it fails due to the port not being available.
EDIT: see #105 for feedback on this issue, fyi
closing to cleanup issue list, comments or questions still welcome, if needed
Hello together,
I am facing the problem that portfinder is blocking a free port because the callback is called directly after calling
server.close()
.The problem is that
server.close()
is an asynchronous operation and as long as theclose
event is not emitted the port is still used by the server (Node API docs: https://nodejs.org/docs/latest/api/net.html#net_server_close_callback):This is where the problem happens: https://github.com/http-party/node-portfinder/blob/master/lib/portfinder.js#L42
With regards, Stefan