Skip to content

Commit

Permalink
don't prefer the port 4321, otherwise users might be confused by the …
Browse files Browse the repository at this point in the history
…error message "createTcpServer: address already in use", which is currently impossible to suppress: rstudio/httpuv#194
  • Loading branch information
yihui committed Feb 14, 2019
1 parent c201606 commit d2bf036
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/chrome.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ chrome_print = function(
)
sv = servr::httd(
dirname(url), daemon = TRUE, browser = FALSE, verbose = FALSE,
initpath = httpuv::encodeURIComponent(basename(url))
port = random_port(), initpath = httpuv::encodeURIComponent(basename(url))
)
on.exit(sv$stop_server(), add = TRUE)
url = sv$url
Expand All @@ -74,7 +74,7 @@ chrome_print = function(
'--headless', '--no-first-run', '--no-default-browser-check'
))

debug_port = servr::random_port()
debug_port = random_port()
ps = processx::process$new(browser, c(
paste0('--remote-debugging-port=', debug_port),
paste0('--user-data-dir=', work_dir), extra_args
Expand Down
4 changes: 4 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ merge_list = function(x, y) {
x[names(y)] = y
x
}

# don't prefer the port 4321 (otherwise we may see the meaningless error message
# "createTcpServer: address already in use" too often)
random_port = function() servr::random_port(NULL)

0 comments on commit d2bf036

Please sign in to comment.