Function in downloadhandler run twice in RStudio Mac

bug
rstudio

#1

I have a download button, which will generate some files, pack to a zip then let user download it. It’s something like this:

content = function(file) {
  save_shapefiles <- function(hrange_list, ud_levels) {...}
  cat("function started")
  build_shapefile_zip(file, save_shapefiles(hrange_list, ud_levels))
  cat("function ended")
}

I found the build_shapefile_zip actually was run twice, thus create two set of temp directories and files. The print message proved that

  1. After clicking download button, there is this file dialog asking for file name
  2. Now the build_shapefile_zip function has run once.
  3. Accept the default file name, save file, close the dialog. The function run the 2nd time.

This seemed to be specific to RStudio Mac builtin browser, which have an empty browser window. Run app in chrome will download the file directly (without asking file name), and only run function once.

This should be a bug of safari, but I’m wondering if it can be fixed from RStudio/Shiny side.


#2

I has reproduced this bug with the official download example, and filed the bug in github.

However I’m not sure if it will get noticed since there are >200 issues there.