Merge pull request #10562 from thalesmg/fix-webhook-async-shutdown-normal-reply-r50

fix(webhook): treat `{shutdown, normal}` and `{closed, _}` async replies as retriable
This commit is contained in:
Thales Macedo Garitezi 2023-05-02 10:08:18 -03:00 committed by GitHub
commit 654d274039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 2 deletions

View File

@ -306,7 +306,20 @@ on_query(
Retry Retry
) )
of of
{error, Reason} when Reason =:= econnrefused; Reason =:= timeout -> {error, Reason} when
Reason =:= econnrefused;
Reason =:= timeout;
Reason =:= {shutdown, normal};
Reason =:= {shutdown, closed}
->
?SLOG(warning, #{
msg => "http_connector_do_request_failed",
reason => Reason,
connector => InstId
}),
{error, {recoverable_error, Reason}};
{error, {closed, _Message} = Reason} ->
%% _Message = "The connection was lost."
?SLOG(warning, #{ ?SLOG(warning, #{
msg => "http_connector_do_request_failed", msg => "http_connector_do_request_failed",
reason => Reason, reason => Reason,
@ -568,7 +581,16 @@ reply_delegator(ReplyFunAndArgs, Result) ->
case Result of case Result of
%% The normal reason happens when the HTTP connection times out before %% The normal reason happens when the HTTP connection times out before
%% the request has been fully processed %% the request has been fully processed
{error, Reason} when Reason =:= econnrefused; Reason =:= timeout; Reason =:= normal -> {error, Reason} when
Reason =:= econnrefused;
Reason =:= timeout;
Reason =:= normal;
Reason =:= {shutdown, normal}
->
Result1 = {error, {recoverable_error, Reason}},
emqx_resource:apply_reply_fun(ReplyFunAndArgs, Result1);
{error, {closed, _Message} = Reason} ->
%% _Message = "The connection was lost."
Result1 = {error, {recoverable_error, Reason}}, Result1 = {error, {recoverable_error, Reason}},
emqx_resource:apply_reply_fun(ReplyFunAndArgs, Result1); emqx_resource:apply_reply_fun(ReplyFunAndArgs, Result1);
_ -> _ ->