servor
servor copied to clipboard
Starting two instances of Servor without port cause them having the same port
Using the API, I start two instances of Servor without waiting the first promise to finish, without port specified, the net
library cause them to have the same port.
If I just do this it works:
const usePort = (port = 0) =>
new Promise((ok, x) => {
setTimeout(() => {
const s = net.createServer();
s.on('error', x);
s.listen(port, () => (a = s.address()) && s.close(() => ok(a.port)));
})
});
They have two differents ports, (51159 and 51160 for example).
Hey 👋 thanks for the report.. just so that I am clear whats going on, you do something like this:
import servor from 'servor';
servor({ ... })
servor({ ... })
And this results in both servers running on the same port?
Exactly !