MatijaL
Strange behaviour when using LiveView Uploads on Fly.io - {:error, :enoent} but not every time
Hi,
I have a small LiveView app deployed on Fly.io and sometimes, when uploading an image, I encounter strange behavior. I click browse, I select image and image preview shows, I click submit and image is uploaded, this is how it should work and works most of the time, but sometimes, something happens and uploading breaks.
In fly logs, I get {:error, :enoent} error. I used dbg to see if the file exists, and it does. So, the file exists and when it should be copied from /tmp/ folder to /uploads folder, it breaks for some reason.
As I already mentioned, this is happening only sometimes, most of the time it works fine and that makes it quite hard to debug. This doesn’t happen on my dev machine. Do you have any idea what could be causing this kind of behavior?
FILE EXISTS: /tmp/plug-1711-iIkC/live_view_upload-1711634767-822835485870-1
COPY ERROR: enoent
[lib/myapp/helpers/file_manager.ex:60: MyApp.Helpers.FileManager.copy_file/2]
path #=> "/tmp/plug-1711-iIkC/live_view_upload-1711634767-822835485870-1"
[lib/myapp/helpers/file_manager.ex:61: MyApp.Helpers.FileManager.copy_file/2]
dest #=> "/uploads/tmp/live_view_upload-1711634767-822835485870-1.jpg"
warning: consuming uploads requires a return signature matching:
{:ok, value} | {:postpone, value}
got:
{:error, :enoent}
defp copy_file(path, dest) do
case File.cp(path, dest) do
:ok ->
{:ok, nil}
{:error, reason} ->
{:error, reason}
end
end
First Post!
kokolegorille
Maybe it has to do with the tmp file being deleted after the process ends?
Did this happen for big image files?
Do You try to save in async mode?
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
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









