title: Using standard R shiny progress bar in parallel foreach calculations
body: <p>I am trying to use the standard R shiny progress bar in a parallel foreach loop using the doParallel back-end. However, this results in the following error message:</p>
  
  <blockquote>
    <p>Warning: Error in {: task 1 failed - "'session' is not a ShinySession object."</p>
  </blockquote>
  
  <h1>Code (minimum working example)</h1>
  
  <pre><code>library(shiny)
  library(doParallel)
  
  ui &lt;- fluidPage(
    actionButton(inputId = "go", label = "Launch calculation")
  )
  
  server &lt;- function(input, output, session) {
  
    workers=makeCluster(2)
    registerDoParallel(workers)
  
    observeEvent(input$go, {
      Runs=c(1:4)
      Test_out=foreach(i=Runs, .combine=cbind, .inorder=TRUE, .packages=c("shiny"),.export=c("session")) %dopar% { 
        pbShiny = shiny::Progress$new()
        pbShiny &lt;- Progress$new(session,min = 0, max = 10)
        on.exit(pbShiny$close())
        test_vec=rep(0,100)
  
        for(i in 1:10){
          test_vec=test_vec+rnorm(100)
          pbShiny$set(message="Simulating",detail=paste(i),
                    value=i)
          Sys.sleep(0.2)
        }
  
      }
    })
  }
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>The code runs if I run the foreach loop sequentially (using registerDoSEQ()).
  Does anyone know how to resolve this issue?</p>
  
  <hr>
  
  <h1>Overall Goal</h1>
  
  <ul>
  <li>Show progress to user in a parallel foreach loop using the doParallel
  back-end in shiny </li>
  <li>User should be aware of the number of workers and
  the progress per worker and or overall progress</li>
  </ul>
  
  <hr>
  
  <p>There is a similar question under the following link, but it didn't get resolved as no working example was provided:</p>
  
  <p><a href="https://stackoverflow.com/questions/54120429/utilizing-parallel-foreach-for-progress-bar-in-r-shiny/54530922#54530922">Utilizing parallel foreach for progress bar in R Shiny</a></p>