rstudio / shinyloadtest

Tools for load testing Shiny applications
https://rstudio.github.io/shinyloadtest
108 stars 22 forks source link

`record_session` fails with error in `writeLines`: invalid connection #169

Open ppm1337 opened 2 days ago

ppm1337 commented 2 days ago

I am unable to successfully execute the shinyloadtest workflow. The recording.log from shinyloadtest::record_session seems to be fine despite an error but the subsequent report generation fails.

Running shinyloadtest::record_session("http://127.0.0.1:1234") produces the following output (mind the error in the end):

Listening on 127.0.0.1:8600 Navigating to: http://127.0.0.1:8600/ Browsing http://127.0.0.1:8600/ Client connected Client connected Client disconnected Stopping server Note: uploaded files to keep with recording file: recording.log.post.0 recording.log.post.1 recording.log.post.2 recording.log.post.3 recording.log.post.4 recording.log.post.5 recording.log.post.6 recording.log.post.7 Server disconnected Client disconnected Error in writeLines(format(evt), private$outputFile) : invalid connection later: exception occurred while executing callback: invoke_wrapped: throwing std::runtime_error

After manually adding the line{"type":"WS_CLOSE","begin":"2024-03-25T08:57:35.607Z"}, loading the runs goes through but with shinyloadtest::load_runs producing the following warnings:

Could not find a valid maintenance period. Make sure at least one complete iteration exists between the latest user st Setting the maintenance period to be whole run. Warning messages: 1: In readLines(recording_path) : incomplete final line found on '[...]' 2: In readLines(file_name) : incomplete final line found on '[...]' 3: In readLines(recording_path) : incomplete final line found on '[...]' 4: In readLines(recording_path) : incomplete final line found on '[...]'

Then, the report generation via shinyloadtest::shinyloadtest_report fails with:

async_extended_task_3-10_users - Concurrency Legend [=================================================>] 437/440 eta: 0sError: x must be a gtable

Here is the code that eventually lead to the error:

n_users <- c(3, 5, 10)
run_name <- "async_extended_task"

result <- do.call(
    shinyloadtest::load_runs,
    setNames(
        as.list(sprintf("<path_to_shinycannon_output>/%s_%s_users", run_name, n_users)),
        paste(n_users, "users")
    )
)

shinyloadtest::shinyloadtest_report(
    result, sprintf("%s_%s-%s_users.html", run_name, min(n_users), max(n_users)),
    self_contained = TRUE
)

The problem could probably be fixed by making sure that the session is successfully recorded but I can't get rid of the Error in writeLines(format(evt), private$outputFile) : invalid connection, which is odd because the output file is written and has contents. Any idea on how to resolve this?

session info:

  • Session info ---------------------------------------------------------------------------------------------------------- setting value version R version 4.3.2 (2023-10-31 ucrt) os Windows 10 x64 (build 19045)
    system x86_64, mingw32 ui RTerm language (EN) collate English_Belgium.1252 ctype English_Belgium.1252 tz Europe/Brussels date 2024-07-02 pandoc 3.1.9 @ (via rmarkdown)

  • Packages --------------------------------------------------------------------------------------------------------------
    package * version date (UTC) lib source bit 4.0.5 2022-11-15 [1] CRAN (R 4.3.3) bit64 4.0.5 2020-08-30 [1] CRAN (R 4.3.3) cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.3) colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.3.3) crayon 1.5.2 2022-09-29 [1] CRAN (R 4.3.3) curl 5.2.1 2024-03-01 [1] CRAN (R 4.3.3) digest 0.6.35 2024-03-11 [1] CRAN (R 4.3.3) dplyr 1.1.4 2023-11-17 [1] CRAN (R 4.3.3) evaluate 0.23 2023-11-01 [1] CRAN (R 4.3.3) fansi 1.0.6 2023-12-08 [1] CRAN (R 4.3.3) farver 2.1.1 2022-07-06 [1] CRAN (R 4.3.3) fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.3) generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.3) ggplot2 3.5.0 2024-02-23 [1] CRAN (R 4.3.3) glue 1.7.0 2024-01-09 [1] CRAN (R 4.3.3) gtable 0.3.4 2023-08-21 [1] CRAN (R 4.3.3) hms 1.1.3 2023-03-21 [1] CRAN (R 4.3.3) htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.3.3) httpuv 1.6.14 2024-01-26 [1] CRAN (R 4.3.3) jsonlite 1.8.8 2023-12-04 [1] CRAN (R 4.3.3) knitr 1.45 2023-10-30 [1] CRAN (R 4.3.3) labeling 0.4.3 2023-08-29 [1] CRAN (R 4.3.1) later 1.3.2 2023-12-06 [1] CRAN (R 4.3.3) lattice 0.21-9 2023-10-01 [2] CRAN (R 4.3.2) lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.3) lubridate 1.9.3 2023-09-27 [1] CRAN (R 4.3.3) magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.3) Matrix 1.6-1.1 2023-09-18 [2] CRAN (R 4.3.2) mgcv 1.9-0 2023-07-11 [2] CRAN (R 4.3.2) munsell 0.5.0 2018-06-12 [1] CRAN (R 4.3.3) nlme 3.1-163 2023-08-09 [2] CRAN (R 4.3.2) pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.3) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.3) prettyunits 1.2.0 2023-09-24 [1] CRAN (R 4.3.3) progress 1.2.3 2023-12-06 [1] CRAN (R 4.3.3) promises 1.2.1 2023-08-10 [1] CRAN (R 4.3.3) R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.3) ragg 1.3.0 2024-03-13 [1] CRAN (R 4.3.3) Rcpp 1.0.12 2024-01-09 [1] CRAN (R 4.3.3) rlang 1.1.3 2024-01-10 [1] CRAN (R 4.3.3) rmarkdown 2.26 2024-03-05 [1] CRAN (R 4.3.3) scales 1.3.0 2023-11-28 [1] CRAN (R 4.3.3) sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.3) shinyloadtest 1.1.0 2021-02-11 [1] CRAN (R 4.3.3) stringi 1.8.3 2023-12-11 [1] CRAN (R 4.3.2) stringr 1.5.1 2023-11-14 [1] CRAN (R 4.3.3) svglite 2.1.3 2023-12-08 [1] CRAN (R 4.3.3) systemfonts 1.0.6 2024-03-07 [1] CRAN (R 4.3.3) textshaping 0.3.7 2023-10-09 [1] CRAN (R 4.3.3) tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.3) tidyselect 1.2.1 2024-03-11 [1] CRAN (R 4.3.3) timechange 0.3.0 2024-01-18 [1] CRAN (R 4.3.3) tzdb 0.4.0 2023-05-12 [1] CRAN (R 4.3.3) utf8 1.2.4 2023-10-22 [1] CRAN (R 4.3.3) vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.3) vroom 1.6.5 2023-12-05 [1] CRAN (R 4.3.3) websocket 1.4.1 2021-08-18 [1] CRAN (R 4.3.3) withr 3.0.0 2024-01-16 [1] CRAN (R 4.3.3) xfun 0.42 2024-02-08 [1] CRAN (R 4.3.3) xml2 1.3.6 2023-12-04 [1] CRAN (R 4.3.3)