Thank you for your replies. Joe, I did not try exactly what you show, but I have tested that mclapply runs and does what it's supposed to do on the server without any reactivity. Robin, my setup is similar to your code. However, when I clicked on the link, your code was not working.
The issue is embedded within a relatively complex Shiny app. When I tried to make a simpler example, I could not replicate the problem. Here's a little more specific description of the problem.
The problem occurs with this statement:
haz_test <- reactive({ analysis_test( ..., input$nmbr, session) })
where
input$nmbr is a numericInput defined in ui.R
analysis_test() is a function that calls mclapply() with mc.cores=10
When the app starts, the above works fine on the 1st call. mclapply() is called within analysis_test() and executes properly. But then while the app is running, when I change the value of input$nmbr, analysis_test() does not get called again in response to the change. It is as if the reactivity is broken. It doesn't recognize that input$nmbr changed, and analysis_test() does not get called. If I change to mc.cores=1, then the reactivity works fine. Also if I insert "input$nmbr" explicitly like the following, then it works fine even with mc.cores = 10!! It is a very strange problem. I can not replicate it with a small example (I tried), And I can't share the code that it happens in. The same issue happens with both Chrome and Firefox, and when I run it in Rstudio viewer window.
haz_test <- reactive({
input$nmbr
analysis_test( ..., input$nmbr, session)
})