crossposting from https://stackoverflow.com/questions/53079904/shiny-future-error-in-ctxoninvalidate-reactive-context-was-created-in-one
I have the below server code which is giving the error when future() is used while it works without future/promises. The reactive values qt_files$file1
, qt_files$file2
and ile_ped$ped
are called in both the future() functions. Could this be the source of error?
server <- function(input, output, session) {
dom_content <- reactiveVal()
observeEvent(input$dom_run, {
prog <- Progress$new(session)
prog$set(message = "Analysis in progress",
detail = "This may take a while...",
value = NULL)
qt_files <- gqt_list() ###calling reactive values to be used in future
ile_ped <- ed_file()
future({
system("cat qt_files$file1 ile_ped$ped")
system("cat qt_files$file2 ile_ped$ped")
###the two system commands give the output "dom.gz" which is returned to R
dom_vcf <- vcfR::read.vcfR("dom.gz")
dom_out <- cbind(vcfR::getFIX(dom_vcf,getINFO = TRUE), dom_vcf@gt)
dom_out
}) %...>%
dom_content() %>%
finally(~prog$close())
return(NULL)
})
observeEvent(dom_content(), {
updateTabsetPanel(session, "dom_tab", "dom_results")
output$dom_table <-
DT::renderDataTable(DT::datatable(
req(dom_content())
))
output$dom_summary <- renderText(paste("Total filtered:",nrow(dom_content())))
})
rec_content <- reactiveVal()
observeEvent(input$rec_run, {
prog <- Progress$new(session)
prog$set(message = "Analysis in progress",
detail = "This may take a while...",
value = NULL)
qt_files <- gqt_list() ###calling reactive values to be used in future
ile_ped <- ed_file()
future({
system("cat qt_files$file1 ile_ped$ped")
system("cat qt_files$file2 ile_ped$ped")
###the two system commands give the output "rec.gz" which is returned to R
rec_vcf <- vcfR::read.vcfR("rec.gz")
rec_out <- cbind(vcfR::getFIX(rec_vcf,getINFO = TRUE), rec_vcf@gt)
rec_out
}) %...>%
rec_content() %>%
finally(~prog$close())
return(NULL)
})
observeEvent(rec_content(), {
updateTabsetPanel(session, "rec_tab", "rec_results")
output$rec_table <-
DT::renderDataTable(DT::datatable(
req(rec_content())
))
output$rec_summary <- renderText(paste("Total filtered:",nrow(rec_content())))
})
}
Error in ctx$onInvalidate: Reactive context was created in one process and accessed from another