Intermittent test errors with Ecto sandbox

That happens because you have a long running process that uses the connection during the test, then the test terminates, and it tries to use the connection again but it cannot because the owner process (the test) is done.

You need to do like @mbaeuerle and explicitly terminate any process that may got ahold of the connection. But remember to do it inside the test itself and not inside an on_exit callback.

3 Likes