From b00709905aacde393d19e4533f5be1204d92f300 Mon Sep 17 00:00:00 2001 From: Anupama Singh Date: Tue, 22 Jul 2025 21:11:07 +0200 Subject: [PATCH 1/2] kill h2_stream process in case of timeouts --- src/grpcbox_client.erl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/grpcbox_client.erl b/src/grpcbox_client.erl index b00b487..05a30c8 100644 --- a/src/grpcbox_client.erl +++ b/src/grpcbox_client.erl @@ -225,6 +225,13 @@ recv(Type, #{stream_id := Id, {error, unknown} end after Timeout -> + %% Kill the stream process to prevent resource leaks + case erlang:is_process_alive(Pid) of + true -> + h2_stream:stop(Pid); + false -> + ok + end, {error, timeout} end. @@ -251,6 +258,13 @@ recv_end(#{stream_id := StreamId, {'DOWN', Ref, process, Pid, Reason} -> {error, {stream_down, Reason}} after Timeout -> + %% Kill the stream process to prevent resource leaks + case erlang:is_process_alive(Pid) of + true -> + h2_stream:stop(Pid); + false -> + ok + end, {error, timeout} end. From a9135f993968b3534bfb46d90b6f39f1fb079c21 Mon Sep 17 00:00:00 2001 From: Anupama Singh Date: Wed, 23 Jul 2025 10:07:41 +0200 Subject: [PATCH 2/2] kill h2_stream process in case of timeouts --- src/grpcbox_client.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/grpcbox_client.erl b/src/grpcbox_client.erl index 05a30c8..a171726 100644 --- a/src/grpcbox_client.erl +++ b/src/grpcbox_client.erl @@ -225,7 +225,7 @@ recv(Type, #{stream_id := Id, {error, unknown} end after Timeout -> - %% Kill the stream process to prevent resource leaks + %% Kill the stream process to prevent process leaks case erlang:is_process_alive(Pid) of true -> h2_stream:stop(Pid); @@ -258,7 +258,7 @@ recv_end(#{stream_id := StreamId, {'DOWN', Ref, process, Pid, Reason} -> {error, {stream_down, Reason}} after Timeout -> - %% Kill the stream process to prevent resource leaks + %% Kill the stream process to prevent process leaks case erlang:is_process_alive(Pid) of true -> h2_stream:stop(Pid);