Skip to content

Can only use Progress$new() inside a Shiny app #628

@tklejmont

Description

@tklejmont

Hi folks,

I have a Shiny app that's retrieving data from BigQuery using DBI and bigrquery packages. When I try to run the app from RStudio IDE I get the following error:

Error message and error stack

> rlang::last_trace(drop = FALSE)
<error/rlang_error>
Error in `initialize()`:
! Can only use Progress$new() inside a Shiny app
---
Backtrace:
     ▆
  1. ├─shiny::runApp()
  2. │ └─appParts$onStart()
  3. │   └─shiny::loadSupport(appDir, renv = sharedEnv, globalrenv = globalenv())
  4. │     ├─withr::with_dir(...)
  5. │     │ └─base::force(code)
  6. │     └─shiny:::sourceUTF8(basename(globalPath), envir = globalrenv)
  7. │       └─base::eval(exprs, envir)
  8. │         └─base::eval(exprs, envir)
  9. ├─shiny::..stacktraceon..(...)
 10. ├─base::source("./data_and_connections.R")
 11. │ ├─base::withVisible(eval(ei, envir))
 12. │ └─base::eval(ei, envir)
 13. │   └─base::eval(ei, envir)
 14. ├─DBI::dbGetQuery(con, "select * from table") at ./data_and_connections.R:75:1
 15. └─DBI::dbGetQuery(con, "select * from table")
 16.   └─DBI (local) .local(conn, statement, ...)
 17.     ├─DBI::dbSendQuery(conn, statement, ...)
 18.     └─bigrquery::dbSendQuery(conn, statement, ...)
 19.       └─bigrquery (local) .local(conn, statement, ...)
 20.         └─bigrquery:::BigQueryResult(...)
 21.           └─bigrquery::bq_job_wait(job, quiet = conn@quiet)
 22.             └─cli::cli_progress_update()
 23.               └─h$add(pb, .envir = .envir)
 24.                 └─asNamespace("shiny")$Progress$new(...)
 25.                   └─shiny (local) initialize(...)
 26.                     └─rlang::abort("Can only use Progress$new() inside a Shiny app")

This seems to happen during the time when a progress bar would be displayed in console to show data chunks being downloaded from BigQuery. If I limit the query to 10K rows which fits in a single chunk, the error will not come up. Does it somehow not identify that this is in fact a Shiny app? It runs fine when deployed to RStudio Connect.

Only showing the relevant code to authenticate to BQ and pull data:

library(DBI)
library(bigrquery)
library(config)

config <- config::get()

con <- dbConnect(
  bigrquery::bigquery(),
  project = config$project_id,
  dataset = config$dataset,
  billing = config$project_id
)

output <- dbGetQuery(con,"select * from table")

Session info:

> sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] bigrquery_1.5.1       RColorBrewer_1.1-3    openssl_2.1.0         gargle_1.5.2          shinyFeedback_0.4.0   tidyr_1.3.0           DataCombine_0.2.21   
 [8] lubridate_1.9.2       openxlsx_4.2.5.2      dplyr_1.1.2           jsonlite_1.8.7        RJDBC_0.2-10          rJava_1.0-6           DBI_1.2.2            
[15] DT_0.28               htmlwidgets_1.6.2     shinyalert_3.0.0      shinyjs_2.1.0         shinycssloaders_1.0.0 shinyWidgets_0.7.6    shinydashboard_0.7.2 
[22] shiny_1.7.4.1        

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10       prettyunits_1.1.1 digest_0.6.33     utf8_1.2.4        mime_0.12         R6_2.5.1          httr_1.4.7        pillar_1.9.0     
 [9] rlang_1.1.2       curl_5.0.1        rstudioapi_0.15.0 data.table_1.14.8 fontawesome_0.5.1 jquerylib_0.1.4   config_0.3.1      bit_4.0.5        
[17] compiler_4.2.3    httpuv_1.6.11     pkgconfig_2.0.3   askpass_1.1       htmltools_0.5.5   tidyselect_1.2.0  tibble_3.2.1      codetools_0.2-19 
[25] fansi_1.0.5       crayon_1.5.2      withr_2.5.0       later_1.3.1       brio_1.1.3        xtable_1.8-4      lifecycle_1.0.4   magrittr_2.0.3   
[33] zip_2.3.0         cli_3.6.2         stringi_1.7.12    cachem_1.0.8      renv_1.0.2        fs_1.6.3          promises_1.2.0.1  bslib_0.5.0      
[41] ellipsis_0.3.2    generics_0.1.3    vctrs_0.6.4       tools_4.2.3       bit64_4.0.5       glue_1.7.0        purrr_1.0.1       crosstalk_1.2.0  
[49] fastmap_1.1.1     yaml_2.3.7        timechange_0.2.0  memoise_2.0.1     sass_0.4.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions