IEx.pry() And Multiple Processes // Debugging Multiple Processes

I’ve noticed that when I’m using IEx.pry() with LiveView in a fairly complex application with lots of processes interacting, when I throw an IEx.pry, the REPL session can be “eaten” by a crash/timeout in another process, and I’ll lose the context in the REPL. It’s very annoying and can make debugging a PITA.

Is there a solution for this? I’d like to have pry, but that it totally pauses all other processes until I’m done. Does this exist?


No. That’s not possible on the beam. I’d suggest looking at tracing instead of pry().

It’s not perfect, but I’ve found a hacky little solution that works for me.

I’ve packaged it up as a project here: GitHub - Miserlou/Spry: Spry is a slightly enhanced `pry` for Elixir

UPD, sorry I didn’t read the latest reply :stuck_out_tongue:

Well, you can try one of these solutions, but none of them will be generic.

  1. You can try to :sys.suspend processes which cause timeout before calling the IEx.pry
  2. You can try to tolerate the exits in links with Process.flag :trap_exit, true

But I’d just suggest to connect iex into running system, and debug the system using :sys module. It is very powerful and can change processes’ state in runtime, suspend/resume processes and show debug information such as received and sent messages

If :sysdon’t cover your needs, you can always use oldschool tracing. But for me, :sys and provide 99% of necessary information and solve 99% of problems

This is basically what spry does, it’ll call :erlang.suspend_process on everything it can find and safely suspend, and then :erlang.resume_process on everything it halted once the session is over. It’s like using a sledgehammer to crack an egg, but it works for me.

1 Like