I am struggling to debug my shiny app that has been deployed on the shiny server. It works fine locally, and it correctly deploys to the server but when I try to click the action button to return a get request it disconnects from the server. I think it has something to do with the promises in my code.
Here is the log I am getting from shiny server:
85: promiseDomain$onThen
84: action
77: promise
76: promise$then
75: then
74: %...>%
73: getFile
72: observeEventHandler
1: runApp
And the code is something like this:
library(ggplot2)
library(dplyr)
library(lubridate)
library(promises)
library(future)
library(httr)
plan(multisession)
ColombiaStations <- c("541853724", "12345678")
source("./qc_functions.R")
ui <- shinyUI(fluidPage(
title = "CSV Service",
Panel(
selectInput("station", "Pick a station", choices = ColombiaStations),
actionButton('getStationData', 'Get station data',
)
)
)
server <- function(input, session, output){session$onSessionEnded(stopApp)
observeEvent(input$getStationData, getFile(input$station))
}
shinyApp(ui, server)
**qc_functions.R**
getFile<- function(station) {
urlCSV <- paste0("http://url-where-the-data-is",station)
data <- future(GET(urlCSV)) %...>% cleanFile()
}
cleanFile <- function(response) {
data <- content(response)
write.csv(data, file="output.csv")
}
Note that this is a simplified version, and in reality I am cleaning up the file in the cleanFile function. Just wondering what's going wrong here?
Thanks