From ac81afee1bc04db8de292f05abbe48a6e4bc1e06 Mon Sep 17 00:00:00 2001 From: Xavier Vello Date: Mon, 6 May 2024 16:03:24 +0200 Subject: [PATCH] don't retry on NoPublicIPv4Error --- hook-worker/src/worker.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/hook-worker/src/worker.rs b/hook-worker/src/worker.rs index 7e2693e..03cfeed 100644 --- a/hook-worker/src/worker.rs +++ b/hook-worker/src/worker.rs @@ -18,8 +18,10 @@ use reqwest::{header, Client}; use tokio::sync; use tracing::error; -use crate::dns::PublicIPv4Resolver; -use crate::error::{WebhookError, WebhookParseError, WebhookRequestError, WorkerError}; +use crate::dns::{NoPublicIPv4Error, PublicIPv4Resolver}; +use crate::error::{ + is_error_source, WebhookError, WebhookParseError, WebhookRequestError, WorkerError, +}; use crate::util::first_n_bytes_of_response; /// A WebhookJob is any `PgQueueJob` with `WebhookJobParameters` and `WebhookJobMetadata`. @@ -401,10 +403,19 @@ async fn send_webhook( .body(body) .send() .await - .map_err(|e| WebhookRequestError::RetryableRequestError { - error: e, - response: None, - retry_after: None, + .map_err(|e| { + if is_error_source::(&e) { + WebhookRequestError::NonRetryableRetryableRequestError { + error: e, + response: None, + } + } else { + WebhookRequestError::RetryableRequestError { + error: e, + response: None, + retry_after: None, + } + } })?; let retry_after = parse_retry_after_header(response.headers());