Random errors after code change


I’m having random issues with Elixir and mix and erlang dependencies.

I have erlang-idna and hackney locally installed and references in deps.
The reason is that sometimes I get weird random error in idna, so I wanted to put some logging to find what’s going on.

Now other errors occur.

Usually after some code change when I run a script using mix run ./scripts/run.exs …

$ mix run ./scripts/run.exs http://www.smartwalls.cz
===> Compiling idna
===> Compiling hackney
Compiling 1 file (.ex)

18:12:11.600 [info]  Application hackney exited: exited in: :hackney_app.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, {:shutdown, {:failed_to_start_child, :hackney_manager, {:EXIT, {:undef, [{:hackney_manager, :start_link, [], []}, {:supervisor, :do_start_child_i, 3, [file: 'supervisor.erl', line: 379]}, {:supervisor, :do_start_child, 2, [file: 'supervisor.erl', line: 365]}, {:supervisor, :"-start_children/2-fun-0-", 3, [file: 'supervisor.erl', line: 349]}, {:supervisor, :children_map, 4, [file: 'supervisor.erl', line: 1157]}, {:supervisor, :init_children, 2, [file: 'supervisor.erl', line: 315]}, {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 374]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 342]}]}}}}}
            (hackney) .../hackney/src/hackney_sup.erl:27: :hackney_sup.start_link/0
            (kernel) application_master.erl:277: :application_master.start_it_old/4

Sometimes it throws that :hackney module is not available or some :hackney.process function is not defined, however when I run the mix again and or run mix compile, it starts to work without any code change.

Could this be some elixir or mix bug?

1 Like

Sometimes I got this error

** (exit) {:bad_label, {:alabel, 'The label "www"  is not a valid A-label: ulabel error=undef'}}
    (idna) ../erlang-idna/src/idna.erl:283: :idna.alabel/1
    (idna) ../erlang-idna/src/idna.erl:145: :idna.encode_1/2
    (hackney) ../hackney/src/hackney_url.erl:100: :hackney_url.normalize/2
    (hackney)  ../hackney/src/hackney.erl:306: :hackney.request/5
    (httpoison) lib/httpoison/base.ex:746: HTTPoison.Base.request/6
    (title_fetch) lib/title_fetch.ex:9: TitleFetch.fetch/1

And the undef is from some call function when caught and undef for exit reason in Erlang is when “The function cannot be found when evaluating a function call.”

So this could be related and there seems to be something wrong with recompilation possibly …

I don’t know if this is any help but the error message is that the supervisor couldn’t find the module :hackney_manager or it does not contain the function :start_link/0 which seems less likely. Are you sure all the hackney modules have been compiled and are in the right place? Try just doing mix compile and check afterwards.


well, the problem is with the compilation, but it gets compiled. As you can see in the output.
Usually what fixes the issue is to remove the _build and/or run mix deps.compile, then it works, but after some other changes in my application that depends on these, it appears again, or similar problem that some hackney module is not available. So I have to run deps.compile again and it’s kind of annoying almost always after some code change compile dependencies and remove build.

And I just wonder if it’s just a normal flow or possibly some compiling issue?

The only thing I can then think of is that you are not finding the newly compiled version or it isn’t visible where it should be. Try finding all the hackney_manager modules when it works and then check if they are all there with new times after you changed them and it doesn’t work.

I am not a mix expert so I don’t really know what it should do and how it handles code upgrading.

1 Like