sineed
Phoenix.LiveViewTest.render_upload/3 crashes after 1 second timeout during IO heavy load
Hello everyone!
Currently I experience a flaky error on dedicated CI when I call Phoenix.LiveViewTest.render_upload/3 function. This function works by splitting file by chunks and sending a message with a chunk via Phoenix.Channel to the Phoenix.LiveView.UploadChannel module. This module on its turn makes a file write operation and responds back that it finished. All good if it happens less than 1 second otherwise I see the following error:
test/my_app/live/my_component_test.exs:10
** (exit) exited in: GenServer.call(#PID<0.23470.0>, {:chunk, "good-image.png", 100, #PID<0.23467.0>, #Phoenix.LiveViewTest.Element<selector: "#my-form input[type=\"file\"][name=\"file\"]", text_filter: nil, ...>}, 5000)
** (EXIT) time out
code: |> upload_image("good-image.png")
stacktrace:
(elixir 1.13.4) lib/gen_server.ex:1030: GenServer.call/3
(phoenix_live_view 0.17.9) lib/phoenix_live_view/test/upload_client.ex:25: Phoenix.LiveViewTest.UploadClient.chunk/4
(phoenix_live_view 0.17.9) lib/phoenix_live_view/test/live_view_test.ex:1752: Phoenix.LiveViewTest.render_chunk/3
test/my_app/live/components/my_component_test.exs:20: MyApp.MyComponentTest.upload_image/2
test/my_app/live/components/my_component_test:10: (test)
Implementation for reference: phoenix_live_view/lib/phoenix_live_view/test/upload_client.ex at main · phoenixframework/phoenix_live_view · GitHub.
The simplest way to fix that would be to increase the timeout. But it may not help in long term if the IO load will get higher. I assume if the goal is to have stable tests then the test with render_upload/3 should pass even if there are resource limits. I also thought about messaging but it’s already there: UploadClient waits for a message and fallbacks to exit(:timeout) after 1 second.
Is increasing timeout the only way to resolve that? Any suggestions?
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









