Fl4m3Ph03n1x

Fl4m3Ph03n1x

Can't get recon_trace to work with anon function

Background

I have an app constantly logging the following error:

=ERROR REPORT==== 18-Jun-2019::11:30:55.362697 ===
Unexpected message: {#Ref<0.1587460723.3280207877.77462>,badarg}

At first I thought that one of our GenServers with a handle_info callback was missing a clause. But now after some research I concluded that the process receiving this message doesn’t even have a handle_info callback implemented because I used recon_trace to spy on all modules that have implementations of handle_info and none was receiving messages like the one above.

Objective

My objective is now to, given a module, check for all the messages it receives, and print those who contain a tuple with the following format: {reference, any}

To achieve this I am trying to use recon_trace:

filter = fn args ->
  has_tuples? = Enum.any?(args, fn x ->
    case x do
      {ref, _reason} when is_reference(ref) -> true
       _ -> false
    end
  end)

  case has_tuples? do
    true  -> :ok
    false -> :nok
  end
end

:recon_trace.calls({hd(mods), :_, filter}, 10)

Error

However I can’t get this code to run due to the following error:

Error: fun with body matching ('=' in body) is illegal as match_spec
** (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

What am I doing wrong?

Marked As Solved

NobbZ

NobbZ

Just importing a module doesn’t change anything… You need to actually use the provided macros…

In your case it should be enough to replace fn by fun.

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
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
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
New

Other popular topics Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36432 110
New

We're in Beta

About us Mission Statement