rstudio / shiny-server

Host Shiny applications over the web.
https://rstudio.com/shiny/server
Other
716 stars 289 forks source link

Work around bug in SockJS upgrade #499

Closed jcheng5 closed 3 years ago

jcheng5 commented 3 years ago

It's issue five six three in sockjs/sockjs-client

Testing notes

Run the following app and follow the instructions in the browser. When the bug exists, it ONLY manifests when running with xhr-streaming, xhr-polling, or jsonp-polling protocols; so use the protocol selector UI to disable all protocols except the one you're trying to test.

library(shiny)

ui <- fluidPage(
  tags$p(
    tags$strong("Instructions: "),
    "Press \"Cause error\". The correct behavior is for the counter to keep counting; the buggy behavior is for the counter to stop."
  ),
  textOutput("counter"),
  actionButton("go", "Cause error"),
  tags$script(HTML(r"{
    Shiny.addCustomMessageHandler('errorme', function(msg) {
      throw new Error('boom');
    });
  }"))
)

server <- function(input, output, session) {
  i <- 0
  output$counter <- renderText({
    invalidateLater(1000)
    i <<- i + 1
    i
  })

  observeEvent(input$go, {
    session$sendCustomMessage("errorme", list())
  })
}

shinyApp(ui, server)