timkonieczny
I’ve been building the follow-along Rumbl app while reading the Programming Phoenix book and ran into some issues testing my channels. When running the tests I get the following output:
07:31:35.021 [error] Postgrex.Protocol (#PID<0.331.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.665.0> exited
Client #PID<0.668.0> is still using a connection from owner at location:
:prim_inet.send_recv_reply/2
(postgrex 0.15.7) lib/postgrex/protocol.ex:2918: Postgrex.Protocol.do_send/3
(postgrex 0.15.7) lib/postgrex/protocol.ex:1858: Postgrex.Protocol.rebind_execute/4
(ecto_sql 3.4.5) lib/ecto/adapters/sql/sandbox.ex:370: Ecto.Adapters.SQL.Sandbox.Connection.proxy/3
(db_connection 2.3.0) lib/db_connection/holder.ex:316: DBConnection.Holder.holder_apply/4
(db_connection 2.3.0) lib/db_connection.ex:1254: DBConnection.run_execute/5
(db_connection 2.3.0) lib/db_connection.ex:1341: DBConnection.run/6
(db_connection 2.3.0) lib/db_connection.ex:595: DBConnection.execute/4
(ecto_sql 3.4.5) lib/ecto/adapters/postgres/connection.ex:80: Ecto.Adapters.Postgres.Connection.execute/4
(ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:544: Ecto.Adapters.SQL.execute!/4
(ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:526: Ecto.Adapters.SQL.execute/5
(ecto 3.4.6) lib/ecto/repo/queryable.ex:192: Ecto.Repo.Queryable.execute/4
(ecto 3.4.6) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
(rumbl_web 0.1.0) lib/rumbl_web/channels/presence.ex:16: RumblWeb.Presence.fetch/2
(phoenix 1.5.7) lib/phoenix/presence.ex:365: anonymous fn/4 in Phoenix.Presence.Tracker.handle_diff/2
(stdlib 3.13) maps.erl:233: :maps.fold_1/3
(phoenix 1.5.7) lib/phoenix/presence.ex:363: anonymous fn/3 in Phoenix.Presence.Tracker.handle_diff/2
(elixir 1.10.4) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(stdlib 3.13) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
The connection itself was checked out by #PID<0.668.0> at location:
(ecto_sql 3.4.5) lib/ecto/adapters/postgres/connection.ex:80: Ecto.Adapters.Postgres.Connection.execute/4
(ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:544: Ecto.Adapters.SQL.execute!/4
(ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:526: Ecto.Adapters.SQL.execute/5
(ecto 3.4.6) lib/ecto/repo/queryable.ex:192: Ecto.Repo.Queryable.execute/4
(ecto 3.4.6) lib/ecto/repo/queryable.ex:17: Ecto.Repo.Queryable.all/3
(rumbl_web 0.1.0) lib/rumbl_web/channels/presence.ex:16: RumblWeb.Presence.fetch/2
(phoenix 1.5.7) lib/phoenix/presence.ex:365: anonymous fn/4 in Phoenix.Presence.Tracker.handle_diff/2
(stdlib 3.13) maps.erl:233: :maps.fold_1/3
(phoenix 1.5.7) lib/phoenix/presence.ex:363: anonymous fn/3 in Phoenix.Presence.Tracker.handle_diff/2
(elixir 1.10.4) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(stdlib 3.13) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
The docs propose this solution for writing tests in a project that uses Phoenix Presence. I have added the code snippet, but I’m still getting the same errors when running my channel tests.
The setup block of my channel_case.ex (including the snippet from the Docs) looks like this:
`setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Rumbl.Repo)
unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(Rumbl.Repo, {:shared, self()})
end
on_exit(fn ->
for pid <- RumblWeb.Presence.fetchers_pids() do
ref = Process.monitor(pid)
assert_receive {:DOWN, ^ref, _, _, _}, 1000
end
end)
:ok
end`
I’ve tried adding the timer, as suggested in this PR as well, to no avail.
Any help would be appreciated. Thanks!
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming










Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
josevalim
How is your test setup? Are you using the style described in this comment?
timkonieczny
Hey, thanks for the quick reply. I originally haven’t added the
start_owner/stop_ownercalls, but now I have. Sometimes the tests work flawlessly now but I’m still getting errors most of the time.I’m using ecto_sql 3.4.6. The project is an umbrella project with rumbl, rumbl_web and info_sys as apps in it. Here’s my setup block from the channel_case.ex in the rumbl_web app - This should be as described in the comment you mentioned:
And here’s the error I’m getting now:
pawlik
I know it has been two years, but it might help someone else along the way. I had the same issue while following “programming phoenix >= 1.4” and…
Looks like the snippet above was inserted in
apps/rumbl/test/data_case.ex, but when I put it inapps/rumbl_web/test/support/channel_case.exis fixes the issue.As an Elixir/Phoenix noob I can’t explain why or is it even the right way to fix the issue… but it works.