From 0bbb1b3d268cd5e5dc7fd8e1502a6247445e438a Mon Sep 17 00:00:00 2001 From: Charles Bernasconi Date: Thu, 26 Sep 2019 15:51:19 +0200 Subject: [PATCH] Exit transformer on target process exit --- lib/httpoison/base.ex | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/httpoison/base.ex b/lib/httpoison/base.ex index e874c74..53b98c4 100644 --- a/lib/httpoison/base.ex +++ b/lib/httpoison/base.ex @@ -576,6 +576,9 @@ defmodule HTTPoison.Base do process_response_headers, process_response_chunk ) do + # Track the target process so we can exit when it dies + Process.monitor(target) + receive do {:hackney_response, id, {:status, code, _reason}} -> send(target, %HTTPoison.AsyncStatus{id: id, code: process_response_status_code.(code)}) @@ -622,6 +625,10 @@ defmodule HTTPoison.Base do process_response_headers, process_response_chunk ) + + # Exit if the target process dies as this will be a zombie + {:DOWN, _ref, :process, ^target, _reason} -> + :ok end end