From 7af38842bc2c0e759398b7ae7aeb98b15b3a7583 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Fri, 11 Aug 2023 11:34:01 -0400 Subject: [PATCH 1/2] feat(chrome.timeout): Add an option for choosing timeout duration --- R/chrome.R | 5 +++-- R/chromote.R | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/R/chrome.R b/R/chrome.R index 52037c0..9a0f544 100644 --- a/R/chrome.R +++ b/R/chrome.R @@ -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( @@ -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" ) } diff --git a/R/chromote.R b/R/chromote.R index a0c259c..835d6a3 100644 --- a/R/chromote.R +++ b/R/chromote.R @@ -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." + ) ) }) From ba3fd9800ca20afb2a8a5248f7233f7e08013bb5 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Fri, 11 Aug 2023 11:37:03 -0400 Subject: [PATCH 2/2] docs: Add news entry --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 033d2ed..458e623 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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