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

gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
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
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement