Fl4m3Ph03n1x

Fl4m3Ph03n1x

Error when using function in recon_trace.calls

Background

I have an app that is printing the following error every 2 or 3 seconds:

=ERROR REPORT==== 14-Jun-2019::14:31:35.089496 ===
Unexpected message: {#Ref<0.2607974300.3493068808.175359>,badarg}

I want to find out it’s source.

Error

To catch the process responsible, I am using recon_trace the following way (an example follows):

:recon_trace.calls({:system_information, :handle_info, fn({_ref, :badarg}, _state) -> :ok end}, 10)

However this is failing with the following error:

:recon_trace.calls({:system_information, :handle_info, fn({_ref, :badarg}, _state) -> :ok end}, 10)
Error: dbg:fun2ms requires fun with single variable or list parameter
** (CaseClauseError) no case clause matching: {:error, :transform_error}
    (recon) src/recon_trace.erl:494: :recon_trace.validate_tspec/3
    (recon) src/recon_trace.erl:424: :recon_trace."-trace_calls/3-lc$^0/1-0-"/2
    (recon) src/recon_trace.erl:426: :recon_trace.trace_calls/3

I am quite confused here. My interpretation of the documentation suggests this should be possible, based on the following sample (in erlang):

All calls to iolist_to_binary/1 made with a binary as an argument already (kind of useless conversion!): recon_trace:calls({erlang, iolist_to_binary, fun([X]) when is_binary(X) -> ok end}, 10)

Question

What am I doing wrong?

Marked As Solved

NobbZ

NobbZ

Yupp, as I edited it into my post seemingly at the same moment you posted as well :wink:

Also Liked

NobbZ

NobbZ

You need to match on a list of argument in your match func. Similar to how you would specify a list in a MFA tuple.


edit

Back at a computer rather than a mobile:

:recon_trace.calls({:system_information, :handle_info, fn [{_ref, :badarg}, _state]) -> :ok end}, 10)

This might work…

Fl4m3Ph03n1x

Fl4m3Ph03n1x

Like this?

:recon_trace.calls({:system_information, :handle_info, fn([{ref, :badarg}, _state]) when is_reference(ref) -> :ok end}, 10)

Where Next?

Popular in Questions Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
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

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
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
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement