Shiny app works on laptop but not on ShinyPro server


I have a Shiny app that works just fine when I try it on my laptop.
It has, among other things, an observeEvent that saves some outputs to reactiveValues 'main_reactive$europe' and 'main_reactive$shares'.

At the very end of server.r, right after my observeEvent block, I have this code:

 # Ensuring the user can save (download) the resulting shares:
  output$down_shares <- downloadHandler(
    filename = function() {
      paste0(input$downShares, ".csv") 
    content = function(file) {
      if (main_reactive$europe == 1) {
        df_shares <- main_reactive$shares
        write.csv2(df_shares, file, row.names = FALSE)
      } else {
        df_shares <- main_reactive$shares
        write.csv(df_shares, file, row.names = FALSE)

The user can save the results of my observeEvent calculations using this downloadHandler - based on the string s/he provided in input$downShares. And it works on my laptop. But when I run it on RStudiopro server, the download handler is not working - it just shows a string 'down_shares' - and it's not a .csv file ("Save as type" = all files). And when I save it - it's just an empty file without any extension.

I am at my wit's ends. Any idea why this might be happening?
Thank you so much!

Hi Dimitri,

I'm not very experienced with Shiny, but the article Ian wrote here might help, since it addresses some possibilities:

Thank you, mara! It makes sense - but we are not having any of these issues.

Any chance you can create a more minimal "reprex"? Preferably a reproducible example that I can run in my environment using standard datasets perhaps, and that reproduces the error in your environment?

Are you testing this in an RStudio viewer pane? From my experience downloads do not work in the viewer and behave the way you are describing. Try opening the app in a web browser (open in browser button at the top of the viewer).

Actually, we submitted this issue to RStudio support. They were able to replicate the problem. Now, their programmers are looking into it. So, that's not a simple problem.

I created a small example, but, unfortunately, it worked. However, the larger code is correct - it works on a Windows PC. But doesn't work on Linux server. Rstudio support is looking into the issue now.

Very unfortunate! Thanks for taking a look. If you can write back here what resolution you discover, that would be helpful!