Skip to content

Commit

Permalink
chore: update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gadenbuie committed Jan 13, 2025
1 parent f2c3952 commit ba1d748
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions R/find-port.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Exclude unsafe ports from Chrome https://src.chromium.org/viewvc/chrome/trunk/src/net/base/net_util.cc?view=markup#l127
unsafePortList <- c(0, asNamespace("httpuv")[["unsafe_ports"]])

#' Get a random port between 3k and 10k, excluding the blacklist. If a preferred port
#' has already been registered in .globals, use that instead.
#' Get a random port between 3k and 10k, excluding unsafe ports. If a preferred
#' port has already been registered in .globals, use that instead.
#' @importFrom stats runif
#' @noRd
getRandomPort <- function() {
Expand Down Expand Up @@ -40,15 +40,17 @@ findRandomPort <- function() {

if (port == 0) {
stop(
"Unable to start a Plumber server. We were unable to find a free port in 10 tries."
"Unable to start a Plumber server. ",
"We were unable to find a free port in 10 tries."
)
}

as.integer(port)
}

#' Find a port either using the assigned port or randomly search 10 times for an available
#' port. If a port was manually assigned, just return it and assume it will work.
#' Find a port either using the assigned port or randomly search 10 times for an
#' available port. If a port was manually assigned, just return it and assume it
#' will work.
#' @noRd
findPort <- function(port = NULL) {
if (is.null(port)) {
Expand Down

0 comments on commit ba1d748

Please sign in to comment.