Can I automatically set infinite db timeout when in ExUnit trace mode?

When debugging with IEx.pry(), I got used to that I have to run my tests with a special command iex -S mix test --trace ... (otherwise, pry won’t even start, or test cases will timeout too soon).

Unfortunately, that’s not enough when you’re debugging an Ecto-based app/library. If you use the pry debugger during a db transaction, it will timeout, because default Ecto db timeout is 15 s. Thus, when debugging you also have to remember about manually changing your repos db timeout config. Otherwise you’ll see errors like Postgrex.Protocol (#PID<0.16080.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.16746.0> timed out because it queued and checked out the connection for longer than 15000m while debugging and you’ll have to restart the whole test process.

That annoys me! Such manual steps make debugging harder than it should be.

Can I “detect” anyhow that I’m in a mix test --trace mode? Why don’t we change default Ecto timeout settings in such a case to :infinity for all the users in test trace mode?

P.S. The current workaround we found for this problem is to add the following into config/test.exs:

config :my_app, MyApp.Repo,
    (if(System.get_env("CI")) do
    (if(System.get_env("CI")) do

This isn’t perfect yet though, as it’ll make the db timeout infinite also when you’re not in a trace mode. (I don’t know how can I detect “am I in trace mode?”.)

You can probably look at ExUnit.configuration() in test_helpers.exs and reconfigure your repo with different timeouts than the default from there.