You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a shiny app that runs a monte carlo simulation with 500 replications. To do this, I use a for loop and call a function from another package to run the simulation, and then I save the data. The shiny app then produces the results using renderTable.
It is possible that the user could mistakenly enter something that would cause one or more of the simulation replications to fail to converge, triggering a stop in the function I'm calling. If this happens, there is nothing to render in a table. In R, I get a nice error message from the package telling me that the model failed to converge. However, in Shiny, the app just force closes.
I've tried using tryCatch and showNotification. It does show the error briefly, but the app still force closes. I've tried using a validate statement in renderTable to tell it to only render a table if the object exists, but it fails before it gets to the renderTable part of the code. Essentially, the stop function in the function I'm calling will crash the entire app if the user inputs something that triggers the stop function.
Is it possible for Shiny to simply print the fatal error message from the R console instead of defaulting to closing the app?
The text was updated successfully, but these errors were encountered:
It seems like this may have been a deliberate design choice but could possibly be revised - if so, I would like to express support for printing error messages instead of force closing the app! https://community.rstudio.com/t/prevent-observer-crashes/25169/3
Creating a reprex always makes me realize that the problem isn't what I thought it was.
I figured out what's forcing it to close. I added a progress bar from a package called shinybusy. To get shinybusy to recognize that the app was running, I put an eventReactive statement in an observeEvent statement:
example < - eventReactive(input$go {
#some function
})
observeEvent(input$go,{example()})
Forcing the app to observe an event that is hitting a stop function in a package is what causes the app to force close, and is also what causes the app to fail to display the error in renderTable (entirely negating the need to use tryCatch and showNotification).
If you have any advice about observeEvent encapsulating an eventReactive, I'd appreciate it! I really need a progress bar, but I can probably find another way.
I have a shiny app that runs a monte carlo simulation with 500 replications. To do this, I use a for loop and call a function from another package to run the simulation, and then I save the data. The shiny app then produces the results using renderTable.
It is possible that the user could mistakenly enter something that would cause one or more of the simulation replications to fail to converge, triggering a
stop
in the function I'm calling. If this happens, there is nothing to render in a table. In R, I get a nice error message from the package telling me that the model failed to converge. However, in Shiny, the app just force closes.I've tried using
tryCatch
andshowNotification
. It does show the error briefly, but the app still force closes. I've tried using a validate statement in renderTable to tell it to only render a table if the object exists, but it fails before it gets to the renderTable part of the code. Essentially, thestop
function in the function I'm calling will crash the entire app if the user inputs something that triggers thestop
function.Is it possible for Shiny to simply print the fatal error message from the R console instead of defaulting to closing the app?
The text was updated successfully, but these errors were encountered: