ream88
I recently encountered an issue where a partial or functional component was re-rendered multiple times, resulting in an inline function call being executed multiple times as well. This led to multiple database requests instead of just one. The problem was challenging to debug. I initially had some flaky tests and discovered that the issue was not related to render_async which was my first suspect. Instead, something else was happening with my live view. Using an IO.puts call, I found that my function was called six times instead of the expected single call.
I resolved the problem by assigning the specific assigns my function call depended on, rather than using {assigns} when rendering the partial.
My question for the Elixir community is: Is there a way to trace and debug such scenarios? I’m aware of :dbg and the possibility of mocking function calls using mox or similar tools. However, I’m wondering if there’s an existing library that allows setting expectations about function calls and asserting on them.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 8 of 8 Posts
ream88
I now ended up with the following helper for my
ExUnit.Cases:This allows me to tag my tests:
This is better than nothing as it allows me to at least visually see multiple calls of my functions. I will maybe investigate a little bit more to check if I can come up with custom assertions.
LostKobrakai
Take a look at
Extrace. It’ll format traces with elixir syntax over erlang syntax.ream88
Expanded my code now like this:
This allows me to assert on the calls like this:
Will now try to wrap this in a custom macro, so it’s less boiler plate.
ream88
Opps Sunday afternoon programming escalation:
This module can be used similar to
Moxlike this:Now it properly asserts that this function is called
counttimes:Will probably clean it up a little bit more (for example replace the
Any suggestions for a nice name?
Agentwith a properGenServerand implement nicer error messages) and then publish it on hexream88
Well here it is: GitHub - tagbase-io/tracee: Trace function calls in concurrent Elixir processes. · GitHub
dimitarvp
Some description would be nice.
ream88
As soon as its ready for prime time ..
:dbgcrashes sometimes on meream88
0.1.0is out and documented: GitHub - tagbase-io/tracee: Trace function calls in concurrent Elixir processes. · GitHubAlso the Elixir forum post: Tracee - Trace function calls in concurrent Elixir processes