Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing RStudio Shiny app causes error #854

Closed
zross opened this issue Jun 4, 2015 · 8 comments
Closed

Closing RStudio Shiny app causes error #854

zross opened this issue Jun 4, 2015 · 8 comments
Labels
Platform: Windows Bug discovered on Windows that may only repro on Windows Type: Bug 🐛

Comments

@zross
Copy link

zross commented Jun 4, 2015

When launching a Shiny app using runApp() in RStudio by itself everything works fine. When I use runApp() within another function, however, the app launches fine BUT when I close the app window I get an error.

As an example here is a test app:

testapp <- shinyApp(
  ui = bootstrapPage(
    numericInput('n', 'Number of obs', 100),
    plotOutput('plot')
  ),
  server = function(input, output) {
    output$plot <- renderPlot({ hist(runif(input$n)) })
  }
)

If I run:

runApp(testapp)

The app launches just fine and when I close the window I get no errors.

But if I run the runApp function within another function such as:

newRunShiny<-function(theapp){
  runApp(theapp)
}

newRunShiny(testapp)

The app launches fine but when I close the app window I get the error:

Called from: withCallingHandlers(expr, error = function(e) {
    handle <- getOption("shiny.error")
    if (is.function(handle)) 
        handle()
})

Windows 7, RStudio 0.98.1103, R 3.1.2, shiny_0.11.1.9005

@wch
Copy link
Collaborator

wch commented Jun 17, 2015

This sounds like it could be related to #869. However, I'm not able to reproduce the problem on my Win 8.1 VM. I am also using a newer version of RStudio (0.99.370) , R (3.1.3), and Shiny (0.12.1).

I'd suggest first trying with a newer version RStudio, then R, and then Shiny. If it still doesn't work, let us know

@zross
Copy link
Author

zross commented Jun 18, 2015

Thanks for the follow-up. The issues do seem related. I updated and still have the issue though the warning is different. Image is attached but the warning is "Called from: Sys.sleep(0.001)". Again no warning with runApp() by itself but with runApp within a function.

This is not a huge issue but it is a nuisance when developing.

image

Rstudio version of 0.99.446, R 3.2.0 and Shiny 0.12.1.

sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] shiny_0.12.1

loaded via a namespace (and not attached):
[1] R6_2.0.1 htmltools_0.2.6 tools_3.2.0
[4] Rcpp_0.11.6 jsonlite_0.9.16 digest_0.6.8
[7] xtable_1.7-4 httpuv_1.3.2 mime_0.3

@Stan125
Copy link

Stan125 commented May 29, 2016

I have this problem as well with my Add-In GREA. Closing the App causes the sys.sleep() error. The problem is that I have to call runApp within a function, because I can't wrap up an Add-In otherwise. Are there any alternatives to runApp, or known workarounds?

@mgpap
Copy link

mgpap commented Apr 28, 2018

@zross I have in a way the same problem. When i press the hit button then 1000 hi are printed.But if I go and close the app window while it is printing then it crashes.Did you find how to solve it?

ui <- fluidPage(
sidebarLayout(
sidebarPanel(
actionButton("h","hit")
),
mainPanel()
)
)
server <- function(input, output) {
observeEvent(input$h,{
for(i in 1:1000){
print("hi")
)
})
)
shinyApp(ui = ui, server = server)

@alandipert alandipert added Type: Bug 🐛 Platform: Windows Bug discovered on Windows that may only repro on Windows labels Apr 26, 2019
@alandipert
Copy link
Contributor

alandipert commented Apr 26, 2019

Closing because I wasn't able to reproduce this on RStudio 1.2.1304/R 3.5.2/Shiny 1.3.2/Windows 10, so presumably the problem has since been resolved, either via RStudio or Shiny changes.

If you feel the original problem has not been resolved, please don't hesitate to comment further or create new issues.

@pcross-usgs
Copy link

I'm having this same issue with a package I'm working on with a shiny app. Problem only arises when runApp is called from a different function. I can reproduce @zross 's issue above on my windows machine (session Info below). No problems on my Mac.

sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] shinydashboard_0.7.1 markdown_1.1 knitr_1.25 ggridges_0.5.1
[5] cowplot_1.0.0 forcats_0.4.0 stringr_1.4.0 dplyr_0.8.3
[9] purrr_0.3.2 readr_1.3.1 tidyr_1.0.0 tibble_2.1.3
[13] ggplot2_3.2.1 tidyverse_1.2.1 magrittr_1.5 popbio_2.6
[17] reshape2_1.4.3 CWDsims_0.1.0 shiny_1.3.2

loaded via a namespace (and not attached):
[1] Rcpp_1.0.2 lubridate_1.7.4 lattice_0.20-38 sysfonts_0.8 assertthat_0.2.1
[6] zeallot_0.1.0 digest_0.6.21 mime_0.7 R6_2.4.0 cellranger_1.1.0
[11] plyr_1.8.4 backports_1.1.4 httr_1.4.1 pillar_1.4.2 rlang_0.4.0
[16] lazyeval_0.2.2 readxl_1.3.1 rstudioapi_0.10 hexbin_1.27.3 magick_2.2
[21] munsell_0.5.0 broom_0.5.2 xfun_0.10 compiler_3.6.1 httpuv_1.5.2
[26] modelr_0.1.5 pkgconfig_2.0.3 gridGraphics_0.4-1 htmltools_0.3.6 tidyselect_0.2.5
[31] withr_2.1.2 crayon_1.3.4 showtextdb_2.0 later_0.8.0 grid_3.6.1
[36] nlme_3.1-141 jsonlite_1.6 xtable_1.8-4 gtable_0.3.0 lifecycle_0.1.0
[41] scales_1.0.0 cli_1.1.0 stringi_1.4.3 promises_1.0.1 xml2_1.2.2
[46] rvcheck_0.1.5 vctrs_0.2.0 generics_0.0.2 tools_3.6.1 showtext_0.7
[51] ggplotify_0.0.4 glue_1.3.1 hms_0.5.1 rsconnect_0.8.15 colorspace_1.4-1
[56] BiocManager_1.30.4 rvest_0.3.4 ggimage_0.2.3 hexSticker_0.4.6 haven_2.1.1

@wch
Copy link
Collaborator

wch commented Oct 4, 2019

@pcross-usgs We are in the process of releasing a new version of Shiny and many of its supporting packages. Hopefully they will all be on CRAN by the middle of next week, but we can't say for sure.

If, after the packages are on CRAN, you upgrade shiny and still have this problem, please file a new issue (and reference this one).

@pcross-usgs
Copy link

Thanks @wch my application no longer has this issue with shiny, for reasons I don't understand. However, I am still able to recreate the initial error that started this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Windows Bug discovered on Windows that may only repro on Windows Type: Bug 🐛
Projects
None yet
Development

No branches or pull requests

6 participants