-
Notifications
You must be signed in to change notification settings - Fork 609
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
suggestion: remove getAvailablePort()
from @std/net
#5364
Labels
Comments
Edit: A reasonable edge was found in the following code. We'll now instead add documentation advising against the use of this function, in favor of using |
Also the preferredPort feature is not available natively in Deno, yet can be quite useful during development. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I suggest removing
getAvailablePort()
from@std/net
.Since implementation,
Deno.HttpServer.addr.port
became available in Deno 1.43. This satisfies the original problem thatgetAvailablePort()
aimed to solve. Example use:Secondly, at least according to this GitHub search, it's easily replaced with
port: 0
(documentation to be added in denoland/deno#24475).Lastly, the function is susceptible to a race condition (a port that is deemed available becomes unavailable in between calling
getAvailablePort()
and the followingDeno.serve()
, and introduces a dependency when the same functionality is already built into the runtime.Happy to hear thoughts.
CC @harrysolovay @jollytoad @bcheidemann @dominiq007 (I found your repos used this function)
The text was updated successfully, but these errors were encountered: