Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Avoid port collisions #963

Closed
himynameisdave opened this issue Oct 28, 2019 · 2 comments
Closed

Avoid port collisions #963

himynameisdave opened this issue Oct 28, 2019 · 2 comments

Comments

@himynameisdave
Copy link

himynameisdave commented Oct 28, 2019

Is your feature request related to a problem? Please describe.
Sapper currently attempts to run on PORT 3000 (or a provided PORT env var). Sometimes this means it will try to run on a PORT which is already in use, which causes headaches (see #920 && #730).

Describe the solution you'd like
It would be better if, after trying those ports first, it then used something like get-port to find an available port.

Describe alternatives you've considered
I think the Sapper creators have already tried mitigating this with an env variable, which is for sure a step in the right direction.

How important is this feature to you?
Low/Medium. It's a nice to have for folks who understand web development like myself, but I think this could be confusing for someone who is newer. It would be better if the system just found the port for you.

Additional context
Not sure what Sapper's policy is on adding new dependencies, but I would recommend that get-port one as it seems to be fairly well maintained, and I know I've used it in projects in the past with great success.

@swyxio
Copy link

swyxio commented Oct 28, 2019

fyi we already use port-authority

const port = await ports.find(defaultPort);
which does the same job as get-port.

#920 is more about race condition.

#730 is a different issue yet again - not sure the cause.

but basically neither of these are solved by spawning yet more ports. we need to handle/wait for the ones we have better.

@himynameisdave
Copy link
Author

@sw-yx You are right, thanks!

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

No branches or pull requests

2 participants