Skip to content

RStudio crash running Shiny in help example #4363

Closed

Description

@dmurdoch

I put together a help page that ran a Shiny app. It works fine with example(testfn), but if I ask for help on testfn and then click on the "Run examples" link shown at the top of the examples, RStudio locks up and I can't find a way to revive it other than Force Quit.

The source for a simplified example help page is shown below. Here is my sessionInfo:

R version 4.5.2 (2025-10-31)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.7.4

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Toronto
tzcode source: internal

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

other attached packages:
[1] shiny_1.11.1  testpkg_0.1.0

loaded via a namespace (and not attached):
 [1] digest_0.6.37     later_1.4.4       R6_2.6.1         
 [4] httpuv_1.6.16     fastmap_1.2.0     magrittr_2.0.4   
 [7] cachem_1.1.0      memoise_2.0.1     htmltools_0.5.9  
[10] lifecycle_1.0.5   promises_1.5.0    cli_3.6.5        
[13] xtable_1.8-4      sass_0.4.10       jquerylib_0.1.4  
[16] pkgload_1.4.1     compiler_4.5.2    rstudioapi_0.17.1
[19] tools_4.5.2       bslib_0.9.0       mime_0.13        
[22] Rcpp_1.1.0        otel_0.2.0        rlang_1.1.7      
[25] jsonlite_2.0.0   

And here is the sample test page. Use Roxygen to generate the man page in a package, then ?testfn to see the help, and click on "Run examples" there to lock up RStudio.

#' @title test help example
#' @param x
#'
#' @examples
#' # Warning!  Clicking on "Run examples"
#' #           can crash RStudio (and other front ends?).
#' #           Use
#' #
#' #             example("testfn")
#' #
#' #           to run safely.

#' captureVals <- function() {
#'  ui <- shiny::fluidPage(
#'    shiny::sidebarLayout(
#'      shiny::sidebarPanel(
#'        shiny::textInput("the_text", "Enter text to exit")
#'      ),
#'      shiny::textOutput("the_text")
#'    )
#'  )
#'
#'  server <- function(input, output, session) {
#'
#'    output$the_text <- renderText("some text")
#'
#'    shiny::observe({
#'      shiny::req(input$the_text)
#'      shiny::stopApp(returnValue = input$the_text)
#'    })
#'  }
#'
#'  shiny::runApp(shiny::shinyApp(ui, server))
#'  }
#'
#' captureVals()
#'
#' @export
testfn <- function(x) {
  "this is a test"
}

Activity

  1. cpsievert commented on Mar 5, 2026

    @cpsievert
    Collaborator

    Thanks for reporting. Could you share some details on how you're running RStudio and what version? In fact, if you're willing, it might be better to file this issue over at https://github.com/rstudio/rstudio/issues since it's more likely that a fix will have to come from there.

  2. dmurdoch commented on Mar 5, 2026

    @dmurdoch
    Author

    Sure, I'll post the RStudio details there, and link to this one so you'll get them.

  3. cpsievert commented on Mar 5, 2026

    @cpsievert
    Collaborator

    Now that I take another look at the example, do you need the runApp() call? Does removing it happen to fix the issue?

  4. dmurdoch commented on Mar 5, 2026

    @dmurdoch
    Author

    I need runApp() or I won't see the return value from stopApp().

  5. dmurdoch commented on Mar 5, 2026

    @dmurdoch
    Author

    Without runApp() I don't get the same crash. When I click on Run Examples, I see the app show up in the Help pane, but it doesn't work: I can't type any input. Whereas running example(testfn) opens it in a separate window and it works, returning (the start of) what I type in the input box.

  6. gadenbuie commented on Mar 5, 2026

    @gadenbuie
    Member

    I'm pretty certain this is entirely on the RStudio side. My suspicion is that RStudio runs those examples in your session but in a way that doesn't give you direct access to the cancel the process. Thanks for opening the issue in rstudio! I'm going to close this, but feel free to come back if the rstudio team comes to a different conclusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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