From 7b2d92b71457a30757d59a75a3e311adc8d2e3a6 Mon Sep 17 00:00:00 2001 From: Steffen Beyer Date: Tue, 17 Mar 2026 20:11:31 +0100 Subject: [PATCH] fix: Sandbox owner checks in DB connection before exiting The shared sandbox owner process exited without releasing its Postgrex connection, causing intermittent "client exited" error logs on CI. The owner now calls Sandbox.checkin before exiting, and on_exit waits for the owner to finish before switching to manual mode. Co-Authored-By: Claude Opus 4.6 --- test/support/integration_case.ex | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/support/integration_case.ex b/test/support/integration_case.ex index 5c91e3a..f3f96ad 100644 --- a/test/support/integration_case.ex +++ b/test/support/integration_case.ex @@ -47,7 +47,8 @@ defmodule Parrhesia.IntegrationCase do send(test_pid, {:sandbox_ready, self()}) receive do - :stop -> :ok + :stop -> + Sandbox.checkin(Repo) end end) @@ -60,8 +61,16 @@ defmodule Parrhesia.IntegrationCase do Sandbox.mode(Repo, {:shared, owner}) on_exit(fn -> - Sandbox.mode(Repo, :manual) + ref = Process.monitor(owner) send(owner, :stop) + + receive do + {:DOWN, ^ref, :process, ^owner, _reason} -> :ok + after + 5_000 -> :ok + end + + Sandbox.mode(Repo, :manual) end) end