rstudio / reactlog

Shiny Reactivity Visualizer
http://rstudio.github.io/reactlog
Other
121 stars 9 forks source link

reactlog ERROR: 'replacement' is invalid UTF-8 #57

Closed mattflor closed 4 years ago

mattflor commented 4 years ago

Recording issue

The reactlog does not show at all and just throws an ERROR: 'replacement' is invalid UTF-8 if one uses a tibble as input for a reactiveValues() slot. Here's the traceback:

> reactlogShow()
> traceback()
#> 5: sub(..., fixed = TRUE) at renderReactLog.R#25
#> 4: fixed_sub("__DATA__", paste(lines, collapse = "\r\n"), fixed_sub("__TIME__", 
#>        paste0("\"", time, "\""), fixed_sub("<script src=\"defaultLog.js\"></script>", 
#>            "", html))) at renderReactLog.R#31
#> 3: reactlog_render(log, time = as.logical(time), ...) at showReactLog.R#61
#> 2: reactlog::reactlog_show(reactlog(), time = time)
#> 1: reactlogShow()

If I remove the %>% as_tibble() in the observeEvent of the example app below, the reactlog shows just fine.

I am on a Windows 7 x64 machine, full session info available below the code for the example app.

library(tibble)
library(DT)
library(shiny)
#> 
#> Attaching package: 'shiny'
#> The following objects are masked from 'package:DT':
#> 
#>     dataTableOutput, renderDataTable

library(reactlog)
options(shiny.reactlog = TRUE)

datasets <- list(iris = iris, mtcars = mtcars)

ui <- fluidPage(
  fluidRow(
    column(
      width = 5,
      selectInput("select",
        label = h3("Select dataset"),
        choices = list("iris" = "iris", "mtcars" = "mtcars"),
        selected = "iris"
      ),
      DTOutput("dt")
    )
  )
)

server <- function(input, output, session) {
  output$dt <- renderDT(
    datatable(rv$dt, rownames = TRUE),
    server = TRUE
  )

  rv <- reactiveValues()

  observeEvent(input$select, {
    rv$dt <<- datasets[[input$select]] %>%
      head() %>%
      as_tibble() # reactlog works without the as_tibble() call
  })
}

shinyApp(ui, server)
#> 
#> Listening on http://127.0.0.1:6791

Created on 2019-11-21 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> - Session info ---------------------------------------------------------- #> setting value #> version R version 3.6.1 (2019-07-05) #> os Windows 7 x64 SP 1 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate German_Germany.1252 #> ctype German_Germany.1252 #> tz Europe/Berlin #> date 2019-11-21 #> #> - Packages -------------------------------------------------------------- #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [2] CRAN (R 3.6.1) #> backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.1) #> callr 3.3.2 2019-09-22 [2] CRAN (R 3.6.1) #> cli 1.1.0 2019-03-19 [2] CRAN (R 3.6.1) #> crayon 1.3.4 2017-09-16 [2] CRAN (R 3.6.1) #> crosstalk 1.0.0 2016-12-21 [2] CRAN (R 3.6.1) #> curl 4.1 2019-09-16 [2] CRAN (R 3.6.1) #> desc 1.2.0 2018-05-01 [2] CRAN (R 3.6.1) #> devtools 2.2.1 2019-09-24 [2] CRAN (R 3.6.1) #> digest 0.6.22 2019-10-21 [2] CRAN (R 3.6.1) #> DT * 0.9 2019-09-17 [2] CRAN (R 3.6.1) #> ellipsis 0.3.0 2019-09-20 [2] CRAN (R 3.6.1) #> evaluate 0.14 2019-05-28 [2] CRAN (R 3.6.1) #> fastmap 1.0.1 2019-10-08 [2] CRAN (R 3.6.1) #> fs 1.3.1 2019-05-06 [2] CRAN (R 3.6.1) #> glue 1.3.1 2019-03-12 [2] CRAN (R 3.6.1) #> highr 0.8 2019-03-20 [2] CRAN (R 3.6.1) #> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.1) #> htmlwidgets 1.5.1 2019-10-08 [1] CRAN (R 3.6.1) #> httpuv 1.5.2 2019-09-11 [2] CRAN (R 3.6.1) #> httr 1.4.1 2019-08-05 [2] CRAN (R 3.6.1) #> jsonlite 1.6 2018-12-07 [2] CRAN (R 3.6.1) #> knitr 1.25 2019-09-18 [2] CRAN (R 3.6.1) #> later 1.0.0 2019-10-04 [2] CRAN (R 3.6.1) #> magrittr 1.5 2014-11-22 [2] CRAN (R 3.6.1) #> memoise 1.1.0 2017-04-21 [2] CRAN (R 3.6.1) #> mime 0.7 2019-06-11 [2] CRAN (R 3.6.0) #> pillar 1.4.2 2019-06-29 [2] CRAN (R 3.6.1) #> pkgbuild 1.0.6 2019-10-09 [2] CRAN (R 3.6.1) #> pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 3.6.1) #> pkgload 1.0.2 2018-10-29 [2] CRAN (R 3.6.1) #> prettyunits 1.0.2 2015-07-13 [2] CRAN (R 3.6.1) #> processx 3.4.1 2019-07-18 [2] CRAN (R 3.6.1) #> promises 1.1.0 2019-10-04 [2] CRAN (R 3.6.1) #> ps 1.3.0 2018-12-21 [2] CRAN (R 3.6.1) #> R6 2.4.0 2019-02-14 [2] CRAN (R 3.6.1) #> Rcpp 1.0.2 2019-07-25 [2] CRAN (R 3.6.1) #> reactlog * 1.0.0.9000 2019-11-21 [1] local #> remotes 2.1.0 2019-06-24 [2] CRAN (R 3.6.1) #> rlang 0.4.1 2019-10-24 [1] CRAN (R 3.6.1) #> rmarkdown 1.16 2019-10-01 [1] CRAN (R 3.6.1) #> rprojroot 1.3-2 2018-01-03 [2] CRAN (R 3.6.1) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.1) #> shiny * 1.4.0 2019-10-10 [2] CRAN (R 3.6.1) #> stringi 1.4.3 2019-03-12 [2] CRAN (R 3.6.0) #> stringr 1.4.0 2019-02-10 [2] CRAN (R 3.6.1) #> testthat 2.2.1 2019-07-25 [2] CRAN (R 3.6.1) #> tibble * 2.1.3 2019-06-06 [2] CRAN (R 3.6.1) #> usethis 1.5.1 2019-07-04 [2] CRAN (R 3.6.1) #> webshot 0.5.1 2018-09-28 [1] CRAN (R 3.6.1) #> withr 2.1.2 2018-03-15 [2] CRAN (R 3.6.1) #> xfun 0.10 2019-10-01 [1] CRAN (R 3.6.1) #> xml2 1.2.2 2019-08-09 [2] CRAN (R 3.6.1) #> xtable 1.8-4 2019-04-21 [2] CRAN (R 3.6.1) #> yaml 2.2.0 2018-07-25 [2] CRAN (R 3.6.0) #> #> [1] C:/Users/XXX/Documents/R/win-library/3.6 #> [2] C:/Program Files/User/R/R-3.6.1/library ```

Interactive steps to produce bad reactlog recording

Or, if one wants to be able to inspect the error traceback:

schloerke commented 4 years ago

@mattflor Great find! Thank you for the detailed information!

Unfortunately, I can not reproduce this error. I believe the error is caused by Windows.

Can you reply with the output of dput(shiny::reactlog())? This will give me the reactlog produced by shiny to see if there is any odd artifacts being created by your machine.


Can you try the script below? It is my dput output from your example on my machine, and we can use it to compare what your machine produces with the dput call above.

Thank you!

rlog <- structure(list(list(action = "define", reactId = "r3", label = "output$dt", 
    type = "observer", value = " NULL", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.34182), list(action = "createContext", 
    ctxId = "ctx1", label = "output$dt", type = "observer", prevCtxId = NULL, 
    srcref = NULL, srcfile = NULL, session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.34535), list(action = "invalidateStart", 
    reactId = "r3", ctxId = "ctx1", type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.34546), list(action = "asyncStart", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.34565), list(action = "invalidateEnd", 
    reactId = "r3", ctxId = "ctx1", type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.34609), list(action = "define", reactId = "r5", 
    label = "observeEvent(input$select)", type = "observer", 
    value = " NULL", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.34797), list(action = "createContext", 
    ctxId = "ctx2", label = "observeEvent(input$select)", type = "observer", 
    prevCtxId = NULL, srcref = NULL, srcfile = NULL, session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.34812), list(action = "invalidateStart", 
    reactId = "r5", ctxId = "ctx2", type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.34821), list(action = "invalidateEnd", 
    reactId = "r5", ctxId = "ctx2", type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.34833), list(action = "createContext", 
    ctxId = "ctx3", label = "output$dt", type = "observer", prevCtxId = "ctx1", 
    srcref = NULL, srcfile = NULL, session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.36261), list(action = "enter", reactId = "r3", 
    ctxId = "ctx3", type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.36288), list(action = "define", reactId = "r4$dt", 
    label = "reactiveValues8304$dt", type = "reactiveValuesKey", 
    value = " NULL", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.37136), list(action = "dependsOn", reactId = "r3", 
    depOnReactId = "r4$dt", ctxId = "ctx3", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.3716), list(action = "exit", reactId = "r3", 
    ctxId = "ctx3", type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.38521), list(action = "createContext", 
    ctxId = "ctx4", label = "observeEvent(input$select)", type = "observer", 
    prevCtxId = "ctx2", srcref = NULL, srcfile = NULL, session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.38558), list(action = "enter", reactId = "r5", 
    ctxId = "ctx4", type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
    time = 1574357726.38572), list(action = "define", reactId = "r1$select", 
    label = "input$select", type = "reactiveValuesKey", value = " chr \"iris\"", 
    session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357726.38638), 
    list(action = "dependsOn", reactId = "r5", depOnReactId = "r1$select", 
        ctxId = "ctx4", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.38661), list(action = "createContext", 
        ctxId = "ctx5", label = "[isolate]", type = "isolate", 
        prevCtxId = NULL, srcref = NULL, srcfile = NULL, session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.38692), list(action = "isolateEnter", 
        reactId = "r5", ctxId = "ctx5", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.38705), list(action = "dependsOn", 
        reactId = "r5", depOnReactId = "r1$select", ctxId = "ctx5", 
        session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357726.38888), 
    list(action = "valueChange", reactId = "r4$dt", value = "Classes ‘tbl_df’, ‘tbl’ and 'data.frame':\t6 obs. of  5 variables:\n $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4\n $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9\n $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1...", 
        session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357726.39647), 
    list(action = "invalidateStart", reactId = "r4$dt", ctxId = NULL, 
        type = "other", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.39656), list(action = "invalidateStart", 
        reactId = "r3", ctxId = "ctx3", type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.39671), list(action = "dependsOnRemove", 
        reactId = "r3", depOnReactId = "r4$dt", ctxId = "ctx3", 
        session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357726.39739), 
    list(action = "invalidateEnd", reactId = "r3", ctxId = "ctx3", 
        type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.39751), list(action = "invalidateEnd", 
        reactId = "r4$dt", ctxId = NULL, type = "other", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.39764), list(action = "isolateExit", 
        reactId = "r5", ctxId = "ctx5", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.39775), list(action = "isolateInvalidateStart", 
        reactId = "r5", ctxId = "ctx5", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.39782), list(action = "dependsOnRemove", 
        reactId = "r5", depOnReactId = "r1$select", ctxId = "ctx5", 
        session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357726.39794), 
    list(action = "isolateInvalidateEnd", reactId = "r5", ctxId = "ctx5", 
        session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357726.39806), 
    list(action = "exit", reactId = "r5", ctxId = "ctx4", type = "observer", 
        session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357726.39815), 
    list(action = "createContext", ctxId = "ctx6", label = "output$dt", 
        type = "observer", prevCtxId = "ctx3", srcref = NULL, 
        srcfile = NULL, session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.39853), list(action = "enter", reactId = "r3", 
        ctxId = "ctx6", type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.39868), list(action = "dependsOn", 
        reactId = "r3", depOnReactId = "r4$dt", ctxId = "ctx6", 
        session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357726.41753), 
    list(action = "exit", reactId = "r3", ctxId = "ctx6", type = "observer", 
        session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357726.42946), 
    list(action = "asyncStop", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357726.42957), list(action = "idle", session = NULL, 
        time = 1574357726.43315), list(action = "invalidateStart", 
        reactId = "r3", ctxId = "ctx6", type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357842.05819), list(action = "dependsOnRemove", 
        reactId = "r3", depOnReactId = "r4$dt", ctxId = "ctx6", 
        session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357842.05828), 
    list(action = "invalidateEnd", reactId = "r3", ctxId = "ctx6", 
        type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357842.05837), list(action = "invalidateStart", 
        reactId = "r5", ctxId = "ctx4", type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357842.05854), list(action = "dependsOnRemove", 
        reactId = "r5", depOnReactId = "r1$select", ctxId = "ctx4", 
        session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357842.0586), 
    list(action = "invalidateEnd", reactId = "r5", ctxId = "ctx4", 
        type = "observer", session = "8c25b522d1a35cc657c077652fd077bf", 
        time = 1574357842.05868)), version = "1")

reactlog::reactlog_show(rlog)
mattflor commented 4 years ago

@schloerke Yes, I suspected too that this would be one of those Windows issues... Actually, if I run the code you provided I get the exact same error and traceback that I already provided.

Here's what dput(shiny::reactlog()) produces on my machine:

structure(list(list(action = "define", reactId = "r3", label = "output$dt", 
    type = "observer", value = " NULL", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.44541), list(action = "createContext", 
    ctxId = "ctx1", label = "output$dt", type = "observer", prevCtxId = NULL, 
    srcref = NULL, srcfile = NULL, session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.44841), list(action = "invalidateStart", 
    reactId = "r3", ctxId = "ctx1", type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.44841), list(action = "asyncStart", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.44841), list(action = "invalidateEnd", 
    reactId = "r3", ctxId = "ctx1", type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.44941), list(action = "define", reactId = "r5", 
    label = "observeEvent(input$select)", type = "observer", 
    value = " NULL", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.45141), list(action = "createContext", 
    ctxId = "ctx2", label = "observeEvent(input$select)", type = "observer", 
    prevCtxId = NULL, srcref = NULL, srcfile = NULL, session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.45241), list(action = "invalidateStart", 
    reactId = "r5", ctxId = "ctx2", type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.45241), list(action = "invalidateEnd", 
    reactId = "r5", ctxId = "ctx2", type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.45241), list(action = "createContext", 
    ctxId = "ctx3", label = "output$dt", type = "observer", prevCtxId = "ctx1", 
    srcref = NULL, srcfile = NULL, session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.46641), list(action = "enter", reactId = "r3", 
    ctxId = "ctx3", type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.46641), list(action = "define", reactId = "r4$dt", 
    label = "reactiveValues2865$dt", type = "reactiveValuesKey", 
    value = " NULL", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.46941), list(action = "dependsOn", reactId = "r3", 
    depOnReactId = "r4$dt", ctxId = "ctx3", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.46941), list(action = "exit", reactId = "r3", 
    ctxId = "ctx3", type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.48941), list(action = "createContext", 
    ctxId = "ctx4", label = "observeEvent(input$select)", type = "observer", 
    prevCtxId = "ctx2", srcref = NULL, srcfile = NULL, session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.49041), list(action = "enter", reactId = "r5", 
    ctxId = "ctx4", type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
    time = 1574408541.49041), list(action = "define", reactId = "r1$select", 
    label = "input$select", type = "reactiveValuesKey", value = " chr \"iris\"", 
    session = "2ddcc5c5ad7002d5c08f257282ff484e", time = 1574408541.49141), 
    list(action = "dependsOn", reactId = "r5", depOnReactId = "r1$select", 
        ctxId = "ctx4", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
        time = 1574408541.49241), list(action = "createContext", 
        ctxId = "ctx5", label = "[isolate]", type = "isolate", 
        prevCtxId = NULL, srcref = NULL, srcfile = NULL, session = "2ddcc5c5ad7002d5c08f257282ff484e", 
        time = 1574408541.49241), list(action = "isolateEnter", 
        reactId = "r5", ctxId = "ctx5", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
        time = 1574408541.49241), list(action = "dependsOn", 
        reactId = "r5", depOnReactId = "r1$select", ctxId = "ctx5", 
        session = "2ddcc5c5ad7002d5c08f257282ff484e", time = 1574408541.49441), 
    list(action = "isolateExit", reactId = "r5", ctxId = "ctx5", 
        session = "2ddcc5c5ad7002d5c08f257282ff484e", time = 1574408541.52841), 
    list(action = "isolateInvalidateStart", reactId = "r5", ctxId = "ctx5", 
        session = "2ddcc5c5ad7002d5c08f257282ff484e", time = 1574408541.52841), 
    list(action = "dependsOnRemove", reactId = "r5", depOnReactId = "r1$select", 
        ctxId = "ctx5", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
        time = 1574408541.52841), list(action = "isolateInvalidateEnd", 
        reactId = "r5", ctxId = "ctx5", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
        time = 1574408541.52841), list(action = "exit", reactId = "r5", 
        ctxId = "ctx4", type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
        time = 1574408541.52841), list(action = "asyncStop", 
        session = "2ddcc5c5ad7002d5c08f257282ff484e", time = 1574408541.53641), 
    list(action = "idle", session = NULL, time = 1574408541.53741), 
    list(action = "invalidateStart", reactId = "r3", ctxId = "ctx3", 
        type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
        time = 1574408541.53941), list(action = "dependsOnRemove", 
        reactId = "r3", depOnReactId = "r4$dt", ctxId = "ctx3", 
        session = "2ddcc5c5ad7002d5c08f257282ff484e", time = 1574408541.53941), 
    list(action = "invalidateEnd", reactId = "r3", ctxId = "ctx3", 
        type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
        time = 1574408541.53941), list(action = "invalidateStart", 
        reactId = "r5", ctxId = "ctx4", type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
        time = 1574408541.53941), list(action = "dependsOnRemove", 
        reactId = "r5", depOnReactId = "r1$select", ctxId = "ctx4", 
        session = "2ddcc5c5ad7002d5c08f257282ff484e", time = 1574408541.54041), 
    list(action = "invalidateEnd", reactId = "r5", ctxId = "ctx4", 
        type = "observer", session = "2ddcc5c5ad7002d5c08f257282ff484e", 
        time = 1574408541.54041), list(action = "define", reactId = "r8", 
        label = "output$dt", type = "observer", value = " NULL", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.42841), 
    list(action = "createContext", ctxId = "ctx6", label = "output$dt", 
        type = "observer", prevCtxId = NULL, srcref = NULL, srcfile = NULL, 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.42841), 
    list(action = "invalidateStart", reactId = "r8", ctxId = "ctx6", 
        type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.42941), list(action = "asyncStart", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.42941), 
    list(action = "invalidateEnd", reactId = "r8", ctxId = "ctx6", 
        type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.42941), list(action = "define", reactId = "r10", 
        label = "observeEvent(input$select)", type = "observer", 
        value = " NULL", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.43241), list(action = "createContext", 
        ctxId = "ctx7", label = "observeEvent(input$select)", 
        type = "observer", prevCtxId = NULL, srcref = NULL, srcfile = NULL, 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.43341), 
    list(action = "invalidateStart", reactId = "r10", ctxId = "ctx7", 
        type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.43341), list(action = "invalidateEnd", 
        reactId = "r10", ctxId = "ctx7", type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.43341), list(action = "createContext", 
        ctxId = "ctx8", label = "output$dt", type = "observer", 
        prevCtxId = "ctx6", srcref = NULL, srcfile = NULL, session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.43341), list(action = "enter", reactId = "r8", 
        ctxId = "ctx8", type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.43441), list(action = "define", reactId = "r9$dt", 
        label = "reactiveValues9696$dt", type = "reactiveValuesKey", 
        value = " NULL", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.43541), list(action = "dependsOn", 
        reactId = "r8", depOnReactId = "r9$dt", ctxId = "ctx8", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.43641), 
    list(action = "exit", reactId = "r8", ctxId = "ctx8", type = "observer", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.45641), 
    list(action = "createContext", ctxId = "ctx9", label = "observeEvent(input$select)", 
        type = "observer", prevCtxId = "ctx7", srcref = NULL, 
        srcfile = NULL, session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.45741), list(action = "enter", reactId = "r10", 
        ctxId = "ctx9", type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.45841), list(action = "define", reactId = "r6$select", 
        label = "input$select", type = "reactiveValuesKey", value = " chr \"iris\"", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.45941), 
    list(action = "dependsOn", reactId = "r10", depOnReactId = "r6$select", 
        ctxId = "ctx9", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.45941), list(action = "createContext", 
        ctxId = "ctx10", label = "[isolate]", type = "isolate", 
        prevCtxId = NULL, srcref = NULL, srcfile = NULL, session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.46041), list(action = "isolateEnter", 
        reactId = "r10", ctxId = "ctx10", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.46041), list(action = "dependsOn", 
        reactId = "r10", depOnReactId = "r6$select", ctxId = "ctx10", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.46041), 
    list(action = "valueChange", reactId = "r9$dt", value = "Classes ‘tbl_df’, ‘tbl’ and 'data.frame':\t6 obs. of  5 variables:\n $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4\n $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9\n $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1...", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.46541), 
    list(action = "invalidateStart", reactId = "r9$dt", ctxId = NULL, 
        type = "other", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.46541), list(action = "invalidateStart", 
        reactId = "r8", ctxId = "ctx8", type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.46641), list(action = "dependsOnRemove", 
        reactId = "r8", depOnReactId = "r9$dt", ctxId = "ctx8", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.46741), 
    list(action = "invalidateEnd", reactId = "r8", ctxId = "ctx8", 
        type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.46741), list(action = "invalidateEnd", 
        reactId = "r9$dt", ctxId = NULL, type = "other", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.46741), list(action = "isolateExit", 
        reactId = "r10", ctxId = "ctx10", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.46741), list(action = "isolateInvalidateStart", 
        reactId = "r10", ctxId = "ctx10", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.46741), list(action = "dependsOnRemove", 
        reactId = "r10", depOnReactId = "r6$select", ctxId = "ctx10", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.46741), 
    list(action = "isolateInvalidateEnd", reactId = "r10", ctxId = "ctx10", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.46741), 
    list(action = "exit", reactId = "r10", ctxId = "ctx9", type = "observer", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.46741), 
    list(action = "createContext", ctxId = "ctx11", label = "output$dt", 
        type = "observer", prevCtxId = "ctx8", srcref = NULL, 
        srcfile = NULL, session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.46841), list(action = "enter", reactId = "r8", 
        ctxId = "ctx11", type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.46841), list(action = "dependsOn", 
        reactId = "r8", depOnReactId = "r9$dt", ctxId = "ctx11", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.50141), 
    list(action = "exit", reactId = "r8", ctxId = "ctx11", type = "observer", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408568.52541), 
    list(action = "asyncStop", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408568.52541), list(action = "idle", session = NULL, 
        time = 1574408568.52641), list(action = "invalidateStart", 
        reactId = "r8", ctxId = "ctx11", type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408571.40341), list(action = "dependsOnRemove", 
        reactId = "r8", depOnReactId = "r9$dt", ctxId = "ctx11", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408571.40341), 
    list(action = "invalidateEnd", reactId = "r8", ctxId = "ctx11", 
        type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408571.40341), list(action = "invalidateStart", 
        reactId = "r10", ctxId = "ctx9", type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408571.40341), list(action = "dependsOnRemove", 
        reactId = "r10", depOnReactId = "r6$select", ctxId = "ctx9", 
        session = "748573cf0b89bdf39b443672ecff33c3", time = 1574408571.40341), 
    list(action = "invalidateEnd", reactId = "r10", ctxId = "ctx9", 
        type = "observer", session = "748573cf0b89bdf39b443672ecff33c3", 
        time = 1574408571.40341)), version = "1")
mattflor commented 4 years ago

I think I narrowed the error down, please have a look at this part of the cat(replacement) output when the error ocurrs:

{
    "action": "valueChange",
    "reactId": "r4$dt",
    "value": "Classes �tbl_df�, �tbl� and 'data.frame':\t6 obs. of  5 variables:\n $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4\n $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9\n $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1...",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77041
  }

Looking back at the dput output, one can see that classes tbl_dfand tbl are encapsulated by different characters than data.frame:

list(action = "valueChange", reactId = "r4$dt", value = "Classes ‘tbl_df’, ‘tbl’ and 'data.frame':\t6 obs. of  5 variables:\n $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4\n $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9\n $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1...", 
        session = "8c25b522d1a35cc657c077652fd077bf", time = 1574357726.39647),

Here's what I did to cat(replacement):

Browse[1]> cat(replacement)
[
  {
    "action": "define",
    "reactId": "r3",
    "label": "output$dt",
    "type": "observer",
    "value": " NULL",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.68341
  },
  {
    "action": "createContext",
    "ctxId": "ctx1",
    "label": "output$dt",
    "type": "observer",
    "prevCtxId": null,
    "srcref": null,
    "srcfile": null,
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.68541
  },
  {
    "action": "invalidateStart",
    "reactId": "r3",
    "ctxId": "ctx1",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.68541
  },
  {
    "action": "asyncStart",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.68641
  },
  {
    "action": "invalidateEnd",
    "reactId": "r3",
    "ctxId": "ctx1",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.68641
  },
  {
    "action": "define",
    "reactId": "r5",
    "label": "observeEvent(input$select)",
    "type": "observer",
    "value": " NULL",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.68841
  },
  {
    "action": "createContext",
    "ctxId": "ctx2",
    "label": "observeEvent(input$select)",
    "type": "observer",
    "prevCtxId": null,
    "srcref": null,
    "srcfile": null,
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.68941
  },
  {
    "action": "invalidateStart",
    "reactId": "r5",
    "ctxId": "ctx2",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.68941
  },
  {
    "action": "invalidateEnd",
    "reactId": "r5",
    "ctxId": "ctx2",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.68941
  },
  {
    "action": "createContext",
    "ctxId": "ctx3",
    "label": "output$dt",
    "type": "observer",
    "prevCtxId": "ctx1",
    "srcref": null,
    "srcfile": null,
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.70441
  },
  {
    "action": "enter",
    "reactId": "r3",
    "ctxId": "ctx3",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.70441
  },
  {
    "action": "define",
    "reactId": "r4$dt",
    "label": "reactiveValues5108$dt",
    "type": "reactiveValuesKey",
    "value": " NULL",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.70641
  },
  {
    "action": "dependsOn",
    "reactId": "r3",
    "depOnReactId": "r4$dt",
    "ctxId": "ctx3",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.70741
  },
  {
    "action": "exit",
    "reactId": "r3",
    "ctxId": "ctx3",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.75841
  },
  {
    "action": "createContext",
    "ctxId": "ctx4",
    "label": "observeEvent(input$select)",
    "type": "observer",
    "prevCtxId": "ctx2",
    "srcref": null,
    "srcfile": null,
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.75841
  },
  {
    "action": "enter",
    "reactId": "r5",
    "ctxId": "ctx4",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.75941
  },
  {
    "action": "define",
    "reactId": "r1$select",
    "label": "input$select",
    "type": "reactiveValuesKey",
    "value": " chr \"iris\"",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.75941
  },
  {
    "action": "dependsOn",
    "reactId": "r5",
    "depOnReactId": "r1$select",
    "ctxId": "ctx4",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.76041
  },
  {
    "action": "createContext",
    "ctxId": "ctx5",
    "label": "[isolate]",
    "type": "isolate",
    "prevCtxId": null,
    "srcref": null,
    "srcfile": null,
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.76041
  },
  {
    "action": "isolateEnter",
    "reactId": "r5",
    "ctxId": "ctx5",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.76041
  },
  {
    "action": "dependsOn",
    "reactId": "r5",
    "depOnReactId": "r1$select",
    "ctxId": "ctx5",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.76241
  },
  {
    "action": "valueChange",
    "reactId": "r4$dt",
    "value": "Classes �tbl_df�, �tbl� and 'data.frame':\t6 obs. of  5 variables:\n $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4\n $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9\n $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1...",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77041
  },
  {
    "action": "invalidateStart",
    "reactId": "r4$dt",
    "ctxId": null,
    "type": "other",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77041
  },
  {
    "action": "invalidateStart",
    "reactId": "r3",
    "ctxId": "ctx3",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77041
  },
  {
    "action": "dependsOnRemove",
    "reactId": "r3",
    "depOnReactId": "r4$dt",
    "ctxId": "ctx3",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77041
  },
  {
    "action": "invalidateEnd",
    "reactId": "r3",
    "ctxId": "ctx3",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77141
  },
  {
    "action": "invalidateEnd",
    "reactId": "r4$dt",
    "ctxId": null,
    "type": "other",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77141
  },
  {
    "action": "isolateExit",
    "reactId": "r5",
    "ctxId": "ctx5",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77141
  },
  {
    "action": "isolateInvalidateStart",
    "reactId": "r5",
    "ctxId": "ctx5",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77141
  },
  {
    "action": "dependsOnRemove",
    "reactId": "r5",
    "depOnReactId": "r1$select",
    "ctxId": "ctx5",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77141
  },
  {
    "action": "isolateInvalidateEnd",
    "reactId": "r5",
    "ctxId": "ctx5",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77141
  },
  {
    "action": "exit",
    "reactId": "r5",
    "ctxId": "ctx4",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77141
  },
  {
    "action": "createContext",
    "ctxId": "ctx6",
    "label": "output$dt",
    "type": "observer",
    "prevCtxId": "ctx3",
    "srcref": null,
    "srcfile": null,
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77241
  },
  {
    "action": "enter",
    "reactId": "r3",
    "ctxId": "ctx6",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.77241
  },
  {
    "action": "dependsOn",
    "reactId": "r3",
    "depOnReactId": "r4$dt",
    "ctxId": "ctx6",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.85141
  },
  {
    "action": "exit",
    "reactId": "r3",
    "ctxId": "ctx6",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.87241
  },
  {
    "action": "asyncStop",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409014.87241
  },
  {
    "action": "idle",
    "session": null,
    "time": 1574409014.87341
  },
  {
    "action": "invalidateStart",
    "reactId": "r3",
    "ctxId": "ctx6",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409024.88641
  },
  {
    "action": "dependsOnRemove",
    "reactId": "r3",
    "depOnReactId": "r4$dt",
    "ctxId": "ctx6",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409024.88641
  },
  {
    "action": "invalidateEnd",
    "reactId": "r3",
    "ctxId": "ctx6",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409024.88641
  },
  {
    "action": "invalidateStart",
    "reactId": "r5",
    "ctxId": "ctx4",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409024.88741
  },
  {
    "action": "dependsOnRemove",
    "reactId": "r5",
    "depOnReactId": "r1$select",
    "ctxId": "ctx4",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409024.88741
  },
  {
    "action": "invalidateEnd",
    "reactId": "r5",
    "ctxId": "ctx4",
    "type": "observer",
    "session": "dd6f1242985b3eab8244d421730635dd",
    "time": 1574409024.88741
  }
]
schloerke commented 4 years ago

@mattflor Great find!


Ok. Wild ride...


I believe this should work going forward! At the top of your shiny app, I would place this line of code before any library calls:

options(useFancyQuotes = FALSE)

I'm going to look into str and see if this is something I can fix. when reactlog saves the rlog to disk and reads it back.

schloerke commented 4 years ago

@mattflor Followup...

What does sQuote("text", TRUE) look like on your machine?

Mine:

> sQuote("text", TRUE)
[1] "‘text’"

I'm hoping your machine produces question marks for the single quotes. (So I know where the code culprit is.)

(Thank you in advance!)

schloerke commented 4 years ago

I'm thinking sQuote("text", TRUE) will work just fine.

Your dput produces the (correct) special quote character, so it's not an issue with str.

** Looking into when it's saved to JSON and read as a character....

schloerke commented 4 years ago

@mattflor Couple of guesses if you don't mind trying...

Do any of these produce the question mark icons? The current code path of reactlog uses the json only option. I am hoping that both shiny versions below work as expected.

a <- sQuote("text", TRUE)

a
#> [1] "‘text’"

# default
cat(a)
#> ‘text’
tmp <- tempfile()
cat(a, file = tmp)
readLines(tmp)
#> Warning in readLines(tmp): incomplete final line found on '/var/folders/0k/
#> bxg5lhr92sq74mb1d446ql540000gp/T//RtmpvqbQKD/file1598581cbf16'
#> [1] "‘text’"

# json
aj <- jsonlite::toJSON(
  a, pretty = TRUE,
  # from shiny pkg
  null = "null", na = "null",
  auto_unbox = TRUE, digits = getOption("shiny.json.digits", 16),
  use_signif = TRUE, force = TRUE, POSIXt = "ISO8601", UTC = TRUE,
  rownames = FALSE, keep_vec_names = TRUE, strict_atomic = TRUE
)

cat(aj)
#> "‘text’"
tmp2 <- tempfile()
cat(aj, file = tmp2)
readLines(tmp2)
#> Warning in readLines(tmp2): incomplete final line found on '/var/folders/0k/
#> bxg5lhr92sq74mb1d446ql540000gp/T//RtmpvqbQKD/file1598517454183'
#> [1] "\"‘text’\""

# shiny read/write
tmp3 <- tempfile()
shiny:::writeUTF8(a, tmp3)
readLines(tmp3)
#> [1] "‘text’"
shiny:::readUTF8(tmp3)
#> [1] "‘text’"

# json + shiny read/write
tmp4 <- tempfile()
shiny:::writeUTF8(aj, tmp4)
readLines(tmp4)
#> [1] "\"‘text’\""
shiny:::readUTF8(tmp4)
#> [1] "\"‘text’\""

Created on 2019-11-22 by the reprex package (v0.3.0)

mattflor commented 4 years ago

@schloerke That's some nice digging :) I won't have access to my Windows 7 machine until Monday. For now, I've tried your code on a Windows 10 VM running on Ubuntu, looks like your hopes were justified:

a <- sQuote("text", TRUE)

a
#> [1] "‘text’"

# default
cat(a)
#> ‘text’

tmp <- tempfile()
cat(a, file = tmp)
readLines(tmp)
#> Warning in readLines(tmp): unvollständige letzte Zeile in 'C:
#> \Users\XXX\AppData\Local\Temp\RtmpwV9T2p\file22c4a977b75' gefunden
#> [1] "‘text’"

# json
aj <- jsonlite::toJSON(
    a, pretty = TRUE,
    # from shiny pkg
    null = "null", na = "null",
    auto_unbox = TRUE, digits = getOption("shiny.json.digits", 16),
    use_signif = TRUE, force = TRUE, POSIXt = "ISO8601", UTC = TRUE,
    rownames = FALSE, keep_vec_names = TRUE, strict_atomic = TRUE
)

cat(aj)
#> "‘text’"
tmp2 <- tempfile()
cat(aj, file = tmp2)
readLines(tmp2)
#> Warning in readLines(tmp2): unvollständige letzte Zeile in 'C:
#> \Users\XXX\AppData\Local\Temp\RtmpwV9T2p\file22c45f704b11' gefunden
#> [1] "\"‘text’\""

# shiny read/write
tmp3 <- tempfile()
shiny:::writeUTF8(a, tmp3)
readLines(tmp3)
#> [1] "â\200\230textâ\200\231"
shiny:::readUTF8(tmp3)
#> [1] "‘text’"

# json + shiny read/write
tmp4 <- tempfile()
shiny:::writeUTF8(aj, tmp4)
readLines(tmp4)
#> [1] "\"â\200\230textâ\200\231\""
shiny:::readUTF8(tmp4)
#> [1] "\"‘text’\""

Created on 2019-11-23 by the reprex package (v0.3.0)

mattflor commented 4 years ago

And indeed, in the Windows 10 VM, the shiny app reactlog works if I use options(useFancyQuotes = FALSE). I'll check if this also the case on my Windows 7 computer on Monday.

mattflor commented 4 years ago

@schloerke Same behaviour on my Windows 7 machine:

a <- sQuote("text", TRUE)

a
#> [1] "‘text’"

# default
cat(a)
#> ‘text’
tmp <- tempfile()
cat(a, file = tmp)
readLines(tmp)
#> Warning in readLines(tmp): incomplete final line found on 'C:
#> \Users\flor\AppData\Local\Temp\Rtmp2V17t5\file22241fb92404'
#> [1] "‘text’"

# json
aj <- jsonlite::toJSON(
    a, pretty = TRUE,
    # from shiny pkg
    null = "null", na = "null",
    auto_unbox = TRUE, digits = getOption("shiny.json.digits", 16),
    use_signif = TRUE, force = TRUE, POSIXt = "ISO8601", UTC = TRUE,
    rownames = FALSE, keep_vec_names = TRUE, strict_atomic = TRUE
)

cat(aj)
#> "‘text’"
tmp2 <- tempfile()
cat(aj, file = tmp2)
readLines(tmp2)
#> Warning in readLines(tmp2): incomplete final line found on 'C:
#> \Users\flor\AppData\Local\Temp\Rtmp2V17t5\file222419a7ff7'
#> [1] "\"‘text’\""

# shiny read/write
tmp3 <- tempfile()
shiny:::writeUTF8(a, tmp3)
readLines(tmp3)
#> [1] "â\200\230textâ\200\231"
shiny:::readUTF8(tmp3)
#> [1] "‘text’"

# json + shiny read/write
tmp4 <- tempfile()
shiny:::writeUTF8(aj, tmp4)
readLines(tmp4)
#> [1] "\"â\200\230textâ\200\231\""
shiny:::readUTF8(tmp4)
#> [1] "\"‘text’\""

Created on 2019-11-25 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> - Session info ---------------------------------------------------------- #> setting value #> version R version 3.6.1 (2019-07-05) #> os Windows 7 x64 SP 1 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate German_Germany.1252 #> ctype German_Germany.1252 #> tz Europe/Berlin #> date 2019-11-25 #> #> - Packages -------------------------------------------------------------- #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [2] CRAN (R 3.6.1) #> backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.1) #> callr 3.3.2 2019-09-22 [2] CRAN (R 3.6.1) #> cli 1.1.0 2019-03-19 [2] CRAN (R 3.6.1) #> crayon 1.3.4 2017-09-16 [2] CRAN (R 3.6.1) #> desc 1.2.0 2018-05-01 [2] CRAN (R 3.6.1) #> devtools 2.2.1 2019-09-24 [2] CRAN (R 3.6.1) #> digest 0.6.22 2019-10-21 [2] CRAN (R 3.6.1) #> ellipsis 0.3.0 2019-09-20 [2] CRAN (R 3.6.1) #> evaluate 0.14 2019-05-28 [2] CRAN (R 3.6.1) #> fastmap 1.0.1 2019-10-08 [2] CRAN (R 3.6.1) #> fs 1.3.1 2019-05-06 [2] CRAN (R 3.6.1) #> glue 1.3.1 2019-03-12 [2] CRAN (R 3.6.1) #> highr 0.8 2019-03-20 [2] CRAN (R 3.6.1) #> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.1) #> httpuv 1.5.2 2019-09-11 [2] CRAN (R 3.6.1) #> jsonlite 1.6 2018-12-07 [2] CRAN (R 3.6.1) #> knitr 1.25 2019-09-18 [2] CRAN (R 3.6.1) #> later 1.0.0 2019-10-04 [2] CRAN (R 3.6.1) #> magrittr 1.5 2014-11-22 [2] CRAN (R 3.6.1) #> memoise 1.1.0 2017-04-21 [2] CRAN (R 3.6.1) #> mime 0.7 2019-06-11 [2] CRAN (R 3.6.0) #> pkgbuild 1.0.6 2019-10-09 [2] CRAN (R 3.6.1) #> pkgload 1.0.2 2018-10-29 [2] CRAN (R 3.6.1) #> prettyunits 1.0.2 2015-07-13 [2] CRAN (R 3.6.1) #> processx 3.4.1 2019-07-18 [2] CRAN (R 3.6.1) #> promises 1.1.0 2019-10-04 [2] CRAN (R 3.6.1) #> ps 1.3.0 2018-12-21 [2] CRAN (R 3.6.1) #> R6 2.4.0 2019-02-14 [2] CRAN (R 3.6.1) #> Rcpp 1.0.2 2019-07-25 [2] CRAN (R 3.6.1) #> remotes 2.1.0 2019-06-24 [2] CRAN (R 3.6.1) #> rlang 0.4.1 2019-10-24 [1] CRAN (R 3.6.1) #> rmarkdown 1.16 2019-10-01 [1] CRAN (R 3.6.1) #> rprojroot 1.3-2 2018-01-03 [2] CRAN (R 3.6.1) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.1) #> shiny 1.4.0 2019-10-10 [2] CRAN (R 3.6.1) #> stringi 1.4.3 2019-03-12 [2] CRAN (R 3.6.0) #> stringr 1.4.0 2019-02-10 [2] CRAN (R 3.6.1) #> testthat 2.2.1 2019-07-25 [2] CRAN (R 3.6.1) #> usethis 1.5.1 2019-07-04 [2] CRAN (R 3.6.1) #> withr 2.1.2 2018-03-15 [2] CRAN (R 3.6.1) #> xfun 0.10 2019-10-01 [1] CRAN (R 3.6.1) #> xtable 1.8-4 2019-04-21 [2] CRAN (R 3.6.1) #> yaml 2.2.0 2018-07-25 [2] CRAN (R 3.6.0) #> #> [1] C:/Users/XXX/Documents/R/win-library/3.6 #> [2] C:/Program Files/User/R/R-3.6.1/library ```
AlexB4891 commented 4 years ago

Hello, using @mattflor idea, I made some changes in the "value" element given by the function dput , here's my code:

b <- dput(shiny::reactlog())
# attributes(a)
# attributes(b)
rlog <- b %>%
map(~.x %>%
map_at("value",~{y <- .x
y <- gsub("[^0-9A-Za-z///' ]","'" , y ,ignore.case = TRUE)
y <- gsub("''","" , y ,ignore.case = TRUE)
y
})
)
attr(rlog,"version") <- "1"
reactlog::reactlog_show(rlog)