Skip to content

upload_file crashes the Chromote session when path begins with ~ or when uploaded file does not exist #160

Closed

Description

@bersbersbers
  1. Make sure test works:
> devtools::test_active_file("tests/testthat/apps/upload/tests/testthat/test-app-upload.R")

══ Testing test-app-upload.R ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 1 ] Done!
  1. Now replace cars.csv by the absolute path in that file, app$upload_file(file = "/home/bers/shinytest2/tests/testthat/apps/upload/tests/testthat/cars.csv")
devtools::test_active_file("tests/testthat/apps/upload/tests/testthat/test-app-upload.R")

══ Testing test-app-upload.R ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 1 ] Done!
  1. Now replace cars.csv by the ~-path in that file, app$upload_file(file = "~/shinytest2/tests/testthat/apps/upload/tests/testthat/cars.csv")
> devtools::test_active_file("tests/testthat/apps/upload/tests/testthat/test-app-upload.R")

══ Testing test-app-upload.R ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ]

── Error (test-app-upload.R:6:3): Make sure upload can take use a local file ───────────────────────────
Error: Chromote: timed out waiting for response to command Runtime.evaluate
Backtrace:
  1. app$upload_file(file = "~/shinytest2/tests/testthat/apps/upload/tests/testthat/cars.csv")
       at test-app-upload.R:6:2
  2. shinytest2::app_upload_file(...)
       at shinytest2/R/app-driver.R:386:6
  3. self$get_js(...)
       at shinytest2/R/app-driver-upload-file.R:32:2
  4. shinytest2::app_get_js(...)
       at shinytest2/R/app-driver.R:882:6
  5. shinytest2::chromote_eval(...)
       at shinytest2/R/app-driver-expect-js.R:24:2
     ...
       at chromote/R/protocol.R:144:6
  9. self$parent$wait_for(p)
       at chromote/R/chromote_session.R:413:6
 10. chromote:::synchronize(p, loop = private$child_loop)
       at chromote/R/chromote.R:148:6
 14. base::tryCatch(...)
       at chromote/R/synchronize.R:112:4
 15. base tryCatchList(expr, classes, parentenv, handlers)
 16. base tryCatchOne(expr, names, parentenv, handlers[[1L]])
 17. base doTryCatch(return(expr), name, parentenv, handler)

[ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ]
Warning message:
In callback(...) :
  Chromote has received a Inspector.targetCrashed event. This means that the ChromoteSession has probably crashed.
Calls: tryCatch ... tryCatchList -> tryCatchOne -> doTryCatch -> callback
> 
  1. Now change the path to a non-existing file - same error message as above.

3 is easy to fix on the user side with path.expand - I am reporting this because it worked without it in shinytest.
4 could use a better error message if the uploaded file does not exist.

Activity

  1. added this to the v0.0.1 milestone on Apr 4, 2022
  2. added
    bug
    on Apr 4, 2022
  3. added a commit that references this issue on Apr 4, 2022
    fa3595a
  4. added a commit that references this issue on Apr 5, 2022
    b6929ab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions