mirror of
https://github.com/rstudio/shiny.git
synced 2026-01-13 17:08:05 -05:00
* Don't kill the session when a debounced/throttled reactive expr errors Fixes #3581 * Update NEWS with PR number Co-authored-by: Carson Sievert <cpsievert1@gmail.com>
41 lines
945 B
R
41 lines
945 B
R
test_that("can access reactive values directly", {
|
|
reactiveConsole(TRUE)
|
|
on.exit(reactiveConsole(FALSE))
|
|
|
|
x1 <- reactiveVal(1)
|
|
x1(2)
|
|
expect_equal(x1(), 2)
|
|
|
|
x2 <- reactiveValues(a = 1)
|
|
x2$a <- 2
|
|
expect_equal(x2$a, 2)
|
|
|
|
y <- reactive(x1() + x2$a)
|
|
expect_equal(y(), 4)
|
|
})
|
|
|
|
test_that("errors in throttled/debounced reactives are catchable", {
|
|
reactiveConsole(TRUE)
|
|
on.exit(reactiveConsole(FALSE))
|
|
|
|
# In Shiny 1.7 and earlier, if a throttled/debounced reactive threw an error,
|
|
# it would cause internal observers used by the implementations of
|
|
# debounce/throttle to error, which would kill the session. The correct
|
|
# behavior is to only expose the error to consumers of the throttled/debounced
|
|
# reactive.
|
|
|
|
r <- reactive({
|
|
stop("boom")
|
|
})
|
|
|
|
rd <- r %>% debounce(1000)
|
|
rt <- r %>% throttle(1000)
|
|
|
|
observe({
|
|
try(rd(), silent = TRUE)
|
|
try(rt(), silent = TRUE)
|
|
})
|
|
|
|
expect_silent(flushReact())
|
|
})
|