Why does rendering of Rmd file with datatable fails when bslib is used on shinyapps.io?
13:47 14 Jun 2024

[Update 2026-07-24: shinyapps.io apps will migrate to Connect Cloud soon. I tested if the bug occurs there and it does not. So this problem is irrelevant soon. I removed the two test apps discussed below from my account.]

This question might be a bug report but I would appreciate a hint (and potential solution) before filing one at the right place.

I maintain a Shiny app hosted on shinyapps.io which allows the user to generate HTML reports based on Rmd templates. The rendering started to fail after a recent update with a pandoc error indicating an out of memory condition (pandoc document conversion failed with error 137).

I tracked the error down to be caused by a combination of shinyapps.io, bslib and DT used in an Rmd file (minimal reproducible example below).

I would be happy if someone could hint at a possible solution or provide advice for the right place to file a bug report (if it is a bug).

The error only occurs when the app is deployed to shinyapps.io using bslib::page_fluid. When running the app locally, the Rmd rendering works. Hence, I suspect that the pandoc version used at shinyapps.io is the problem but I can not properly test this.

You can find the offending App at https://jali.shinyapps.io/TestApp/. However, pressing the download button will only reproduce the error. I deployed it using the following two files, app.R

ui  <- bslib::page_fluid(
#ui  <- shiny::fluidPage(
  shiny::downloadButton(outputId = "rmd", label = "Render Rmd")
)

server <- function(input, output, session) {
  output$rmd <- shiny::downloadHandler(
    filename = function() {"Report.html"},
    content = function(file) {
      rmarkdown::render(
        input = "template.Rmd",
        output_file = file,
        output_format = rmarkdown::html_document()
      )
    }
  )
}

shiny::shinyApp(ui = ui, server = server)

and template.Rmd

```{r DT, echo=FALSE, comment=NA}
  DT::datatable(data = data.frame("Test"=1:3))
```{}

(Sorry for the extra brackets {} in template.Rmd, didn't know how to format correctly.)

When deploying this app using shiny::fluidPage (see outcommented line in app.R) everything works at shinyapps.io. Also, when printing the test dataframe (not using DT), everything is ok.

Below is the log info from shinyapps.io upon startup and once the download button is clicked to start rendering.

024-06-14T20:45:54.790590+00:00 shinyapps[12177969]: Running on host: 9736844199c4 2024-06-14T20:45:54.795171+00:00 shinyapps[12177969]: Running as user: uid=10001(shiny) gid=10001(shiny) groups=10001(shiny) 2024-06-14T20:45:54.799620+00:00 shinyapps[12177969]: Connect version: 2024.05.0 2024-06-14T20:45:54.804055+00:00 shinyapps[12177969]: LANG: C.UTF-8 2024-06-14T20:45:54.808429+00:00 shinyapps[12177969]: Working directory: /srv/connect/apps/TestApp 2024-06-14T20:45:54.812713+00:00 shinyapps[12177969]: Using R 4.3.1 2024-06-14T20:45:54.816956+00:00 shinyapps[12177969]: R.home(): /opt/R/4.3.1/lib/R 2024-06-14T20:45:54.821404+00:00 shinyapps[12177969]: Content will use current R environment 2024-06-14T20:45:54.825801+00:00 shinyapps[12177969]: R_LIBS: (unset) 2024-06-14T20:45:54.830125+00:00 shinyapps[12177969]: .libPaths(): /usr/lib/R, /opt/R/4.3.1/lib/R/library 2024-06-14T20:45:54.834697+00:00 shinyapps[12177969]: shiny version: 1.8.1.1 2024-06-14T20:45:54.839110+00:00 shinyapps[12177969]: httpuv version: 1.6.15 2024-06-14T20:45:54.843469+00:00 shinyapps[12177969]: rmarkdown version: 2.26 2024-06-14T20:45:54.847983+00:00 shinyapps[12177969]: knitr version: 1.46 2024-06-14T20:45:54.852635+00:00 shinyapps[12177969]: jsonlite version: 1.8.8 2024-06-14T20:45:54.857314+00:00 shinyapps[12177969]: RJSONIO version: (none) 2024-06-14T20:45:54.861731+00:00 shinyapps[12177969]: htmltools version: 0.5.8.1 2024-06-14T20:45:54.866345+00:00 shinyapps[12177969]: reticulate version: (none) 2024-06-14T20:45:54.871717+00:00 shinyapps[12177969]: Using pandoc: /opt/connect/ext/pandoc/2.16 2024-06-14T20:45:54.876316+00:00 shinyapps[12177969]: 2024-06-14T20:45:54.880830+00:00 shinyapps[12177969]: Starting R with process ID: '32' 2024-06-14T20:45:54.885259+00:00 shinyapps[12177969]: Shiny application starting ... 2024-06-14T20:45:54.889983+00:00 shinyapps[12177969]: 2024-06-14T20:45:54.894687+00:00 shinyapps[12177969]: Listening on http://127.0.0.1:43517 2024-06-14T21:01:32.883063+00:00 shinyapps[12177969]: Container event from container-9706893: stop 2024-06-16T07:26:25.472835+00:00 shinyapps[12177969]: Container event from container-9706893: start 2024-06-16T07:26:29.472831+00:00 shinyapps[12177969]: Running on host: c279b780ae28 2024-06-16T07:26:29.477208+00:00 shinyapps[12177969]: Running as user: uid=10001(shiny) gid=10001(shiny) groups=10001(shiny) 2024-06-16T07:26:29.481404+00:00 shinyapps[12177969]: Connect version: 2024.05.0 2024-06-16T07:26:29.485300+00:00 shinyapps[12177969]: LANG: C.UTF-8 2024-06-16T07:26:29.489434+00:00 shinyapps[12177969]: Working directory: /srv/connect/apps/TestApp 2024-06-16T07:26:29.493338+00:00 shinyapps[12177969]: Using R 4.3.1 2024-06-16T07:26:29.497530+00:00 shinyapps[12177969]: R.home(): /opt/R/4.3.1/lib/R 2024-06-16T07:26:29.501755+00:00 shinyapps[12177969]: Content will use current R environment 2024-06-16T07:26:29.505732+00:00 shinyapps[12177969]: R_LIBS: (unset) 2024-06-16T07:26:29.509640+00:00 shinyapps[12177969]: .libPaths(): /usr/lib/R, /opt/R/4.3.1/lib/R/library 2024-06-16T07:26:29.513501+00:00 shinyapps[12177969]: shiny version: 1.8.1.1 2024-06-16T07:26:29.517338+00:00 shinyapps[12177969]: httpuv version: 1.6.15 2024-06-16T07:26:29.521427+00:00 shinyapps[12177969]: rmarkdown version: 2.26 2024-06-16T07:26:29.525431+00:00 shinyapps[12177969]: knitr version: 1.46 2024-06-16T07:26:29.529464+00:00 shinyapps[12177969]: jsonlite version: 1.8.8 2024-06-16T07:26:29.533536+00:00 shinyapps[12177969]: RJSONIO version: (none) 2024-06-16T07:26:29.537638+00:00 shinyapps[12177969]: htmltools version: 0.5.8.1 2024-06-16T07:26:29.541555+00:00 shinyapps[12177969]: reticulate version: (none) 2024-06-16T07:26:29.545694+00:00 shinyapps[12177969]: Using pandoc: /opt/connect/ext/pandoc/2.16 2024-06-16T07:26:29.549708+00:00 shinyapps[12177969]: 2024-06-16T07:26:29.553988+00:00 shinyapps[12177969]: Starting R with process ID: '31' 2024-06-16T07:26:29.558113+00:00 shinyapps[12177969]: Shiny application starting ... 2024-06-16T07:26:29.562294+00:00 shinyapps[12177969]: 2024-06-16T07:26:29.566279+00:00 shinyapps[12177969]: Listening on http://127.0.0.1:44067 [upon click on download button] 2024-06-16T07:29:09.482079+00:00 shinyapps[12177969]: processing file: template.Rmd 2024-06-16T07:29:09.486251+00:00 shinyapps[12177969]: 1/1 [DT] 2024-06-16T07:29:09.490345+00:00 shinyapps[12177969]: output file: template.knit.md 2024-06-16T07:29:09.494372+00:00 shinyapps[12177969]: 2024-06-16T07:29:09.498706+00:00 shinyapps[12177969]: /opt/connect/ext/pandoc/2.16/pandoc +RTS -K512m -RTS template.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/RtmpSCGqEp/file1f4028edb.html --lua-filter /usr/lib/R/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /usr/lib/R/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --section-divs --template /usr/lib/R/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/RtmpSCGqEp/rmarkdown-str1f3159e9ff.html 2024-06-16T07:29:09.503288+00:00 shinyapps[12177969]: [WARNING] This document format requires a nonempty element. 2024-06-16T07:29:09.507894+00:00 shinyapps[12177969]: Defaulting to 'template.knit' as the title. 2024-06-16T07:29:09.511964+00:00 shinyapps[12177969]: To specify a title, use 'title' in metadata or --metadata title="...". 2024-06-16T07:29:12.472491+00:00 shinyapps[12177969]: Killed 2024-06-16T07:29:12.477204+00:00 shinyapps[12177969]: Warning: Error in : pandoc document conversion failed with error 137 2024-06-16T07:29:12.481571+00:00 shinyapps[12177969]: 15: 2024-06-16T07:29:12.486026+00:00 shinyapps[12177969]: 13: fn 2024-06-16T07:29:12.490634+00:00 shinyapps[12177969]: 8: retry 2024-06-16T07:29:12.495090+00:00 shinyapps[12177969]: 7: connect$retryingStartServer 2024-06-16T07:29:12.499435+00:00 shinyapps[12177969]: 6: eval 2024-06-16T07:29:12.503597+00:00 shinyapps[12177969]: 5: eval 2024-06-16T07:29:12.508141+00:00 shinyapps[12177969]: 4: eval 2024-06-16T07:29:12.512594+00:00 shinyapps[12177969]: 3: eval 2024-06-16T07:29:12.516469+00:00 shinyapps[12177969]: 2: eval.parent 2024-06-16T07:29:12.520489+00:00 shinyapps[12177969]: 1: local 2024-06-16T07:29:12.524754+00:00 shinyapps[12177969]: Container event from container-9706893: oom (out of memory)

I deployed TestApp2 which is working as expected because I substituted bslib::page_fluid against shiny::fluidPage.

2024-06-16T07:39:52.344409+00:00 shinyapps[12189076]: Container event from container-9712977: start 2024-06-16T07:39:57.254173+00:00 shinyapps[12189076]: Running on host: 96c659ddd69e 2024-06-16T07:39:57.258816+00:00 shinyapps[12189076]: Running as user: uid=10001(shiny) gid=10001(shiny) groups=10001(shiny) 2024-06-16T07:39:57.262442+00:00 shinyapps[12189076]: Connect version: 2024.05.0 2024-06-16T07:39:57.266250+00:00 shinyapps[12189076]: LANG: C.UTF-8 2024-06-16T07:39:57.269916+00:00 shinyapps[12189076]: Working directory: /srv/connect/apps/TestApp2 2024-06-16T07:39:57.273494+00:00 shinyapps[12189076]: Using R 4.3.1 2024-06-16T07:39:57.276921+00:00 shinyapps[12189076]: R.home(): /opt/R/4.3.1/lib/R 2024-06-16T07:39:57.280807+00:00 shinyapps[12189076]: Content will use current R environment 2024-06-16T07:39:57.284477+00:00 shinyapps[12189076]: R_LIBS: (unset) 2024-06-16T07:39:57.288096+00:00 shinyapps[12189076]: .libPaths(): /usr/lib/R, /opt/R/4.3.1/lib/R/library 2024-06-16T07:39:57.291570+00:00 shinyapps[12189076]: shiny version: 1.8.1.1 2024-06-16T07:39:57.294988+00:00 shinyapps[12189076]: httpuv version: 1.6.15 2024-06-16T07:39:57.299979+00:00 shinyapps[12189076]: rmarkdown version: 2.26 2024-06-16T07:39:57.303475+00:00 shinyapps[12189076]: knitr version: 1.46 2024-06-16T07:39:57.306804+00:00 shinyapps[12189076]: jsonlite version: 1.8.8 2024-06-16T07:39:57.310129+00:00 shinyapps[12189076]: RJSONIO version: (none) 2024-06-16T07:39:57.313536+00:00 shinyapps[12189076]: htmltools version: 0.5.8.1 2024-06-16T07:39:57.316960+00:00 shinyapps[12189076]: reticulate version: (none) 2024-06-16T07:39:57.320797+00:00 shinyapps[12189076]: Using pandoc: /opt/connect/ext/pandoc/2.16 2024-06-16T07:39:57.324269+00:00 shinyapps[12189076]: 2024-06-16T07:39:57.327775+00:00 shinyapps[12189076]: Starting R with process ID: '31' 2024-06-16T07:39:57.331411+00:00 shinyapps[12189076]: Shiny application starting ... 2024-06-16T07:39:57.334956+00:00 shinyapps[12189076]: 2024-06-16T07:39:57.338183+00:00 shinyapps[12189076]: Listening on http://127.0.0.1:36991 [upon click on download button] 2024-06-16T07:40:44.260826+00:00 shinyapps[12189076]: processing file: template.Rmd 2024-06-16T07:40:45.254009+00:00 shinyapps[12189076]: 1/1 [DT] 2024-06-16T07:40:45.258617+00:00 shinyapps[12189076]: output file: template.knit.md 2024-06-16T07:40:45.262315+00:00 shinyapps[12189076]: 2024-06-16T07:40:45.265930+00:00 shinyapps[12189076]: /opt/connect/ext/pandoc/2.16/pandoc +RTS -K512m -RTS template.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/RtmpTYRsUo/file1f6a4bf6bf.html --lua-filter /usr/lib/R/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /usr/lib/R/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --section-divs --template /usr/lib/R/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /tmp/RtmpTYRsUo/rmarkdown-str1f4fd99153.html 2024-06-16T07:40:45.269613+00:00 shinyapps[12189076]: [WARNING] This document format requires a nonempty element. 2024-06-16T07:40:45.273323+00:00 shinyapps[12189076]: Defaulting to 'template.knit' as the title. 2024-06-16T07:40:45.276770+00:00 shinyapps[12189076]: To specify a title, use 'title' in metadata or --metadata title="...". 2024-06-16T07:40:45.280638+00:00 shinyapps[12189076]: 2024-06-16T07:40:45.284455+00:00 shinyapps[12189076]: Output created: /tmp/RtmpTYRsUo/file1f6a4bf6bf.html

Finally the sessionInfo() output of my local machine where both App versions work as expected, generating a HTML report with a DT table.

R version 4.3.1 (2023-06-16 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale: 1 LC_COLLATE=German_Germany.utf8 LC_CTYPE=German_Germany.utf8 LC_MONETARY=German_Germany.utf8 [4] LC_NUMERIC=C LC_TIME=German_Germany.utf8

time zone: Europe/Berlin tzcode source: internal

attached base packages: 1 stats graphics grDevices utils
datasets methods base

loaded via a namespace (and not attached): 1 digest_0.6.35
later_1.3.2 R6_2.5.1 httpuv_1.6.15 fastmap_1.1.1
xfun_0.43 [7] magrittr_2.0.3 cachem_1.0.8
shiny_1.8.1.1 knitr_1.46 htmltools_0.5.8.1 rmarkdown_2.26
[13] lifecycle_1.0.4 promises_1.3.0 cli_3.6.2
askpass_1.2.0 openssl_2.1.2 xtable_1.8-4 [19] sass_0.4.9 rsconnect_1.2.2 jquerylib_0.1.4 compiler_4.3.1
rstudioapi_0.16.0 tools_4.3.1 [25] curl_5.2.1
evaluate_0.23 mime_0.12 bslib_0.7.0 Rcpp_1.0.12
rlang_1.1.3 [31] jsonlite_1.8.8

r shiny pandoc dt bslib