title: shiny app download button and future_promise: Error in enc2utf8: argument is not a character vector
body: <p>I am trying to create a download handler in shiny, but using future_promise() because it is possible that writing the file could take some time. Here is a working example of what I'd like to do, but without using the async framework:</p>
  <p>A working .Rmd shiny app: when you click on the button, it writes 10 random deviates to a file and offers it as a download. I added a delay of 5 seconds.</p>
  <pre><code>---
  title: &quot;download, no futures&quot;
  runtime: shiny
  output: html_document
  ---
  
  ```{r setup, include=FALSE}
  library(dplyr)
  knitr::opts_chunk$set(echo = FALSE)
  ```
  
  This version works.
  
  ```{r}
  renderUI({
    
    button_reactive &lt;- reactive({
      y = rnorm(10)
      Sys.sleep(5)
      tf = tempfile(fileext = &quot;.txt&quot;)
      cat(c(y,'\n'), sep='\n', file = tf)
      d = readBin(con = tf, what = &quot;raw&quot;, n = file.size(tf))
      return(list(fn = basename(tf), d = d))
    })
    
    output$button &lt;- downloadHandler(
        filename = function() {
          button_reactive() %&gt;%
            `[[`('fn')
        },
        content = function(f) {
          d = button_reactive() %&gt;%
            `[[`('d')
          con = file(description = f, open = &quot;wb&quot;)
          writeBin(object = d, con = con)
          close(con)
        }
      )
    
    shiny::downloadButton(outputId = &quot;button&quot;, label=&quot;Download&quot;)
  })
  </code></pre>
  <p>I'm trying to implement this in the async framework using future_promise. Here's the {future}/{promises} version:</p>
  <pre><code>---
  title: &quot;download futures&quot;
  runtime: shiny
  output: html_document
  ---
  
  ```{r setup, include=FALSE}
  library(future)
  library(promises)
  plan(multisession)
  library(dplyr)
  knitr::opts_chunk$set(echo = FALSE)
  ```
  
  This version yields this error on download attempt, reported in the R console:
  
  ```
  Warning: Error in enc2utf8: argument is not a character vector
    [No stack trace available]
  ```
  
  ```{r}
  renderUI({
    
    button_reactive &lt;- reactive({
      future_promise({
        y = rnorm(10)
        Sys.sleep(5)
        tf = tempfile(fileext = &quot;.txt&quot;)
        cat(c(y,'\n'), sep='\n', file = tf)
        d = readBin(con = tf, what = &quot;raw&quot;, n = file.size(tf))
      return(list(fn = basename(tf), d = d))
      }, seed = TRUE)
    })
    
    output$button &lt;- downloadHandler(
        filename = function() {
          button_reactive() %...&gt;%
            `[[`('fn')
        },
        content = function(f) {
          con = file(description = f, open = &quot;wb&quot;)
          d = button_reactive() %...&gt;%
            `[[`('d') %...&gt;%
            writeBin(object = ., con = con)
          close(con)
        }
      )
    
    shiny::downloadButton(outputId = &quot;button&quot;, label=&quot;Download&quot;)
  })
  </code></pre>
  <p>When I click the button in Firefox, I get no file and in the R console, this is shown:</p>
  <pre><code>Warning: Error in enc2utf8: argument is not a character vector
    [No stack trace available]
  </code></pre>
  <p>After some debugging, I believe this occurs because whatever is running the download handler is running the <code>filename</code> function, expecting a character vector, and getting a promise. But I'm not sure how to fix this.</p>
  <p>I saw this <a href="https://stackoverflow.com/questions/56354485/using-promise-object-in-download-handler-in-shiny-r">question</a>, in which the asker seems to have the same problem, but no solution was offered (and their example was not reproducible).</p>
  <p>How can I fix this?</p>