Debugging deployment assets?

In dev and local prod, everything is fine.

However, in my deployment (using Distillery and Gigalixir; will be adding build tools after this), the screen shows “Internal Server Error” and my log shows this bug:

[error] #PID<0.3359.0> running Code6000Web.Endpoint (connection #PID<0.3358.0>, stream id 1) terminated
request_id=180e6a277cd41582489352d361c34291 [info] GET /
Request: GET /
Server: code6000.dev:80 (http)
:erlang.binary_part("", {0, 2})
(ArgumentError) argument error
(exit) an exception was raised:
(fastimage) lib/fastimage.ex:199: Fastimage.get_acc_with_type/3
(code6000) lib/code6000_web/templates/home/1._header.html.eex:20: anonymous fn/2 in Code6000Web.HomeView."1._header.html"/1
(fastimage) lib/fastimage.ex:153: Fastimage.size/2
(fastimage) lib/fastimage.ex:213: Fastimage.info/3
(code6000) lib/code6000_web/templates/home/1._header.html.eex:20: anonymous fn/2 in Code6000Web.HomeView."1._header.html"/1
(elixir) lib/enum.ex:1948: Enum."-reduce/3-lists^foldl/2-0-"/3
(code6000) lib/code6000_web/views/home_view.ex:7: Code6000Web.HomeView.ratio/1
(code6000) lib/code6000_web/templates/home/1._header.html.eex:15: Code6000Web.HomeView."1._header.html"/1
request_id=180e6a277cd41582489352d361c34291 [info] Sent 500 in 745µs
request_id=180e6a277cd41582489352d361c34291 [info] Converted error :badarg to 500 response

CODE:

  def ratio(ext) do
    {:ok, image} = "past_work/#{ext}"
                   |> LayoutView.images_path
                   |> Fastimage.size()
    image.width / image.height
  end

  # layout_view.ex
  def images_path(ext \\ ""), do: Application.app_dir(:code6000, "priv/static/images/#{ext}")

First thing I’d check is your erlang and elixir versions specified in your elixir_buildpack.config. Make sure they match what you have in dev. See https://github.com/HashNuke/heroku-buildpack-elixir/blob/master/README.md#configuration

They match.

Will use the following versions:
       * Stack cedar-14
       * Erlang 20.1
       * Elixir 1.9.0
gigalixir ps
  # ...
  "status": "Healthy", 
  "version": "11"
  # ...

Digging deeper, I think the problem is the image path is empty and binary_part is trying to get the first 2 characters which results in an error.

Can you run gigalixir ps:remote_console and then run
“past_work/foo” |> LayoutView.images_path

And see if it’s empty?

Use :code.priv_dir/1. All the other patches you might get through other patches might not be available in distillery releases.

Followed: https://gigalixir.readthedocs.io/en/latest/main.html#managing-ssh-keys

gigalixir ps:remote_console
--logger-sasl-reports : Unknown option
Node code6000@192.168.102.227 is not running!
Connection to us-west-2.aws.ssh.gigalixir.com closed.
Command '[u'ssh', u'-t', u'root@us-west-2.aws.ssh.gigalixir.com', u'-p', u'32668', u'gigalixir_run', u'remote_console']' returned non-zero exit status 1

Didn’t have this issue before I added .webp assets.

Now tried your switch. Still not working.

Same error in log w/ a few new lines:

"/app/lib/code6000-0.1.0/priv/static/images/past_work/1.webp"

** (File.Error) could not list directory "/tmp/build/_build/prod/lib/code6000/priv/static/images/past_work"

Notably, there isn’t a file named 1.webp

What do you see if you run gigalixir ps:ssh and look inside /app/lib/code6000-0.1.0/priv/static/images? Any files there at all?

K, I’ve identified the issue:

There were some static assets in the deploy build that weren’t part of my local ones.

Those are causing an error because of the reject logic I had.


Cool, fixed the logic by adding a filter

Working now!

1 Like