LiveView upload crashes when sending consume_done, channel has terminated?

error] GenServer #PID<0.1529.0> terminating
** (stop) exited in: GenServer.call(#PID<0.1539.0>, :consume_done, :infinity)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started

This error is occuring at consume_uploaded_entries function

files =
      consume_uploaded_entries(socket, :image, fn %{path: path}, entry ->
        file_details = %{path: path, filename: entry.client_name}
        upload_file = AssetStore.upload_image(dir_name, file_details)

        case upload_file do
          {:ok, file_path} ->
            {:ok,
             %{
               path: file_path,
               name: entry.client_name,
               size: entry.client_size
             }}

          {:error, error} ->
            {:postpone, {:error, error}}
        end
      end)
1 Like

Dumb question, but did your supervisor started the process ?
Or can you show where you started your genserver ?

1 Like

@bilalhassankh I’ve edited the title of this post to be more specific about (what I believe to be) the problem.

The crash you’re describing sounds like the channel process is exiting before the file upload handler finishes; that’s the only place that sends a :consume_done message:

Can you describe the conditions that lead up to this error? What environments does it happen in (dev / test / production)? Is it sensitive to the size of the file?

I think I found the issue. Are you saving the uploaded files into priv/static/? If so, LiveView live reload will (by default and in dev mode) try to reload the page when something changes in this directory. Try changing the file destination or disabling live reload, it worked for me.