Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting two instances of Servor without port cause them having the same port #56

Open
nestarz opened this issue May 24, 2020 · 2 comments

Comments

@nestarz
Copy link

nestarz commented May 24, 2020

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).

@lukejacksonn
Copy link
Owner

lukejacksonn commented May 26, 2020

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?

@nestarz
Copy link
Author

nestarz commented May 26, 2020

Exactly !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants