You will learn:
- Tools for finding bugs & diagnosing errors in Shiny applications
- Little-known ways to look under the hood
- How to debug problems in deployed apps
- Cheat code for OSX IDE JavaScript debug tools
"Finding your bug is a process of confirming the many things that you believe are true — until you find one which is not true."
– Norm Matloff
Author of The Art of R Programming and The Art of Debugging
Breakpoint (armed)
Stepping after execution
shinyServerif (input$bins > 50) browser()
runApp(..., display.mode="showcase")
options(shiny.reactlog=TRUE) runApp(...) showReactLog()
# generate bins based on input$bins from ui.R x <- faithful[, 2] bins <- seq(min(x), max(x), length.out = input$bins + 1) cat(file=stderr(), "drawing histogram with", input$bins, "bins\n")
Listening on http://127.0.0.1:5757 drawing histogram with 30 bins drawing histogram with 35 bins
rsconnect::deployApp( ... ) rsconnect::showLogs(streaming = TRUE)
2016-01-29T01:26:12 shinyapps[77594]: 2016-01-29T01:26:12 shinyapps[77594]: Starting R with process ID: '26' 2016-01-29T01:26:14 shinyapps[77594]: drawing histogram with 30 bins 2016-01-29T01:26:14 shinyapps[77594]: drawing histogram with 35 bins
tail -f /var/log/shiny-server/myapp-20160131-104403-8492.log
Only while R session is alive!
options(shiny.trace = TRUE)
SEND {"config":{"workerId":"","sessionId":"04531d50d12554bd981b24b9d3983cc4"}}
RECV {"method":"init","data":{"bins":30,".clientdata_output_distPlot_width":610,
".clientdata_output_distPlot_height":400,".clientdata_output_distPlot_hidden":false,
".clientdata_pixelratio":1,".clientdata_url_protocol":"http:",
".clientdata_url_hostname":"127.0.0.1",".clientdata_url_port":"5569",
".clientdata_url_pathname":"/",".clientdata_url_search":"",
".clientdata_url_hash_initial":"",".clientdata_singletons":"",
".clientdata_allowDataUriScheme":true}}
bins <- seq(min(x), max(x), length.out = input$bins + 1)
if (input$bins > 40)
stop("too many bins")
Warning: Error in renderPlot: too many bins
Stack trace (innermost first):
76: renderPlot [server.R#20]
68: output$distPlot
1: shiny::runApp
options(shiny.fullstacktrace = TRUE)
Warning: Error in renderPlot: too many bins
Stack trace (innermost first):
79: h
78: .handleSimpleError
77: stop
76: renderPlot [server.R#20]
75: ..stacktraceon..
74: func
...
options(shiny.error = browser)
Right-click, inspect element, Console.
defaults write org.rstudio.RStudio WebKitDeveloperExtras -bool true
Any questions?