diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/PostgreSQL/Test/Utils.pm
index 15b314d1f8..693f2f02e5 100644
--- a/src/test/perl/PostgreSQL/Test/Utils.pm
+++ b/src/test/perl/PostgreSQL/Test/Utils.pm
@@ -426,8 +426,16 @@ sub pump_until
 	while (1)
 	{
 		last if $$stream =~ /$until/;
-		return 0 if ($timeout->is_expired);
-		return 0 if (not $proc->pumpable());
+		if ($timeout->is_expired)
+		{
+			diag("pump_until: timeout expired with stream: \"$$stream\"");
+			return 0;
+		}
+		if (not $proc->pumpable())
+		{
+			diag("pump_until: process terminated unexpectedly with stream: \"$$stream\"");
+			return 0
+		}
 		$proc->pump();
 	}
 	return 1;
