sineed

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?

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44778 311
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement