Skip to content
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
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
when running in Posit Workbench, when available. This allows deploying to
Connect servers without the need to store long-lived credentials.

* Removed support for log streaming from shinyapps.io due to loss of support
for this feature on the shinyapps.io platform (`showLogs(streaming = TRUE)`).
If this feature is important to your workflow, please file an issue and we
will consider reintroduction of log streaming via rsconnect in Connect Cloud.
(#1292)

# rsconnect 1.7.0

* Added support for deploying from `manifest.json` files created by
Expand Down
85 changes: 16 additions & 69 deletions R/applications.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,40 +213,6 @@ applicationTask <- function(taskDef, appName, accountDetails, quiet) {
invisible(NULL)
}

# streams application logs from ShinyApps
streamApplicationLogs <- function(authInfo, applicationId, entries, skip) {
# build the URL
url <- paste0(
serverInfo("shinyapps.io")$url,
"/applications/",
applicationId,
"/logs?",
"count=",
entries,
"&tail=1"
)
parsed <- parseHttpUrl(url)

handle <- createCurlHandle("GET")
curl::handle_setheaders(
handle,
.list = signatureHeaders(authInfo, "GET", parsed$path, NULL)
)

# begin the stream
curl::curl_fetch_stream(
url = url,
fun = function(data) {
if (skip > 0) {
skip <<- skip - 1
} else {
cat(rawToChar(data))
}
},
handle = handle
)
}

#' Application Logs
#'
#' @description
Expand All @@ -267,9 +233,9 @@ streamApplicationLogs <- function(authInfo, applicationId, entries, skip) {
#' @param server Server name. Required only if you use the same account name on
#' multiple servers.
#' @param entries The number of log entries to show. Defaults to 50 entries.
#' @param streaming Whether to stream the logs. If `TRUE`, then the
#' function does not return; instead, log entries are written to the console
#' as they are made, until R is interrupted. Defaults to `FALSE`.
#' @param streaming Deprecated. Streaming logs is not currently supported
#' as the ShinyApps.io backend no longer supports this feature. If `TRUE`,
#' an error will be thrown. Defaults to `FALSE`.
#'
#' @note These functions only work
#' for applications deployed to ShinyApps.io.
Expand All @@ -296,42 +262,23 @@ showLogs <- function(

checkShinyappsServer(deployment$server)

if (streaming) {
cli::cli_abort(
c(
"Streaming logs is not currently supported.",
i = "The ShinyApps.io backend no longer supports the streaming API.",
i = "Use {.arg streaming = FALSE} (the default) to retrieve recent log entries."
)
)
}

accountDetails <- accountInfo(deployment$account, deployment$server)
client <- clientForAccount(accountDetails)
application <- getAppByName(client, accountDetails, deployment$name)

if (streaming) {
# streaming; poll for the entries directly
skip <- 0
repeat {
tryCatch(
{
streamApplicationLogs(accountDetails, application$id, entries, skip)
# after the first fetch, we've seen all recent entries, so show
# only new entries. unfortunately /logs/ doesn't support getting 0
# entries, so get one and don't log it.
entries <- 1
skip <- 1
},
error = function(e) {
# if the server times out, ignore the error; otherwise, let it
# bubble through
if (
!identical(
e$message,
"transfer closed with outstanding read data remaining"
)
) {
stop(e)
}
}
)
}
} else {
# if not streaming, poll for the entries directly
logs <- client$getLogs(application$id, entries)
cat(logs)
}
# Poll for the entries directly
logs <- client$getLogs(application$id, entries)
cat(logs)
}

#' @rdname showLogs
Expand Down
6 changes: 3 additions & 3 deletions man/showLogs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading