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

feat(chrome.timeout): Add an option for choosing timeout duration #120

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

* Fixed #89, #91: `find_chrome()` now checks more possible binary names for Chrome or Chromium on Linux and Mac. (thanks @brianmsm and @rossellhayes, #117)

* Fixed #22: Added a new `chromote.timeout` global option that can be used to set the timeout (in seconds) for establishing connections with the Chrome session. (#120)


# chromote 0.1.1

Expand Down
5 changes: 3 additions & 2 deletions R/chrome.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ launch_chrome_impl <- function(path, args, port) {
)

connected <- FALSE
end <- Sys.time() + 10
timeout <- getOption("chromote.timeout", 10)
end <- Sys.time() + timeout
while (!connected && Sys.time() < end) {
if (!p$is_alive()) {
stop(
Expand Down Expand Up @@ -216,7 +217,7 @@ launch_chrome_impl <- function(path, args, port) {

if (!connected) {
rlang::abort(
"Chrome debugging port not open after 10 seconds.",
paste("Chrome debugging port not open after", timeout, "seconds."),
class = "error_stop_port_search"
)
}
Expand Down
8 changes: 6 additions & 2 deletions R/chromote.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ Chromote <- R6Class(
promise(function(resolve, reject) {
private$ws$onOpen(resolve)
}),
10,
timeout_message = "Chromote: timed out waiting for WebSocket connection to browser."
timeout = getOption("chromote.timeout", 10),
timeout_message = paste0(
"Chromote: timed out waiting for WebSocket connection to browser. ",
"Use `options(chromote.timeout = ", getOption("chromote.timeout", 10), ")` ",
"to increase the timeout."
)
)
})

Expand Down