Goals

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

Non-goals

Outline

We'll cover three main areas:

  • Debugging
  • Tracing
  • Errors

Debugging

"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

Breakpoints

Breakpoint (armed)

Breakpoints

Stepping after execution

Breakpoints

Pros

  • Can inspect local values/stack
  • Can step through following code
  • Doesn't change code

Cons

  • Only works inside shinyServer
  • Can't tell you why something isn't happening
  • Interrupts program flow; not conditional

browser()

Conditional breakpoint

if (input$bins > 50)
  browser()

browser()

Pros

  • Similar advantages to breakpoints
  • Valid anywhere an R expression is valid
  • Can be made conditional

Cons

  • Changes your code!
  • Interrupts program flow
  • Can't tell you why something isn't happening

Tracing

Showcase Mode

runApp(..., display.mode="showcase")