output value greys out and does not refresh when using futures

I have the following code

testUI <- function(id) {                                                                  
  ns <- NS(id)                                                                            
                                                                                          
  return(                                                                                 
      fluidRow(                                                                           
        column(3,                                                                         
          actionButton(ns("sampleButton"), "Sample")                                      
        ),                                                                                
        column(9,                                                                         
          textOutput(ns("infoText"))                                                      
          )                                                                               
        )                                                                                 
      )                                                                                   
}                                                                                         
                                                                                          
testServer <- function(input, output, session) {                                          
                                                                                          
  data <- reactiveVal()                                                                   
                                                                                          
  observeEvent(input$sampleButton,                                                        
  {                                                                                       
    fut <- future::future({return(10)})                                                   
    promises::then(fut,                                                                   
      onFulfilled = function(value) {                                                     
        data(value)                                                                       
      })                 
    return(NULL)                                                                 
  })                                                                                      
                                                                                          
  output$infoText <- renderText({                                                         
    if(is.null(data())) {                                                                 
      return("No data")                                                                   
    } else {                                                                              
      return(paste("data", data()))                                                       
    }                                                                                     
                                                                                          
  })                                                                                      
                                                                                          
}

The future spawns correctly, but when it resolves, the data infoText is not updated. Instead, it greys out. In the websocket I see that there's a "busy": "busy" message, but it never goes back to "busy": "idle".

I am using shiny 1.0.5, promises 1.0.1 and future 1.9.0

Do you have a way to update all or at least some packages? From what I see here, 1.9.0 is more than a year old, so it is very likely that your issue was fixed since then.

I can't do that. I am running on a shiny server that has that version.

Hi @sbo. I check your code as the following. It work well.

library(shiny)

testUI <- function(id) {                                                                  
  ns <- NS(id)                                                                            
  
  return(                                                                                 
    fluidRow(                                                                           
      column(3,                                                                         
             actionButton(ns("sampleButton"), "Sample")                                      
      ),                                                                                
      column(9,                                                                         
             textOutput(ns("infoText"))                                                      
      )                                                                               
    )                                                                                 
  )                                                                                   
}                                                                                         

testServer <- function(input, output, session) {                                          
  
  data <- reactiveVal()                                                                   
  
  observeEvent(input$sampleButton,                                                        
               {                                                                                       
                 fut <- future::future({return(10)})                                                   
                 promises::then(fut,                                                                   
                                onFulfilled = function(value) {                                                     
                                  data(value)                                                                       
                                })                 
                 return(NULL)                                                                 
               })                                                                                      
  
  output$infoText <- renderText({                                                         
    if(is.null(data())) {                                                                 
      return("No data")                                                                   
    } else {                                                                              
      return(paste("data", data()))                                                       
    }                                                                                     
    
  })                                                                                      
  
}

ui <- fluidPage(

  testUI("test")
)

server <- function(input, output, session) {

  callModule(testServer, "test")
}

shinyApp(ui, server)
1 Like

I does not for me. This screenshot shows what I mean. After a few seconds of pressing the button, I get this

@raytong I also tried with promises 1.1.0 and future 1.15.1, same result. Which version of shiny are you using?

@sbo. I still cannot reproduce your problem. My shiny 1.4.0, promises 1.1.0 and future 1.15.1.

Ok, I verified that the problem indeed does not occur with shiny 1.1.0, so it is a bug of 1.0.5.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.