Skip to content

Commit

Permalink
Fixes #1358: more informative error message when calling runApp insid…
Browse files Browse the repository at this point in the history
…e of an app's app.R (or inside ui.R or server.R).
  • Loading branch information
bborgesr committed Dec 15, 2016
1 parent 907b9a9 commit c350e2a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ shiny 0.14.2.9000

### Minor new features and improvements

* Addressed [#1358](https://github.com/rstudio/shiny/issues/1358): more informative error message when calling `runApp()` inside of an app's app.R (or inside ui.R or server.R). ([#1482](https://github.com/rstudio/shiny/pull/1482))

* Added a more descriptive JS warning for `insertUI()` when the selector argument does not match anything in DOM. ([#1488](https://github.com/rstudio/shiny/pull/1488))

* Added support for injecting JavaScript code when the `shiny.testmode` option is set to `TRUE`. This makes it possible to record test events interactively. ([#1464]https://github.com/rstudio/shiny/pull/1464))
Expand Down
12 changes: 12 additions & 0 deletions R/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ serviceApp <- function() {

.shinyServerMinVersion <- '0.3.4'

# Global flag that's TRUE whenever we're inside of the scope of a call to runApp
.globals$running <- FALSE

#' Run Shiny Application
#'
#' Runs a Shiny application. This function normally does not return; interrupt R
Expand Down Expand Up @@ -555,6 +558,15 @@ runApp <- function(appDir=getwd(),
handlerManager$clear()
}, add = TRUE)

if (.globals$running) {
stop("Can't call `runApp()` from within `runApp()`. If your ,",
"application code contains `runApp()`, please remove it.")
}
.globals$running <- TRUE
on.exit({
.globals$running <- FALSE
}, add = TRUE)

# Enable per-app Shiny options
oldOptionSet <- .globals$options
on.exit({
Expand Down

0 comments on commit c350e2a

Please sign in to comment.