From 6a57c2bbf89c1b084caca775d299b1449ccbec3f Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Mon, 3 Apr 2023 14:21:19 +0200 Subject: [PATCH] fix: retry on transient Cloudflare errors --- src/poetry/utils/constants.py | 16 +++++++++++++++- tests/utils/test_authenticator.py | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/poetry/utils/constants.py b/src/poetry/utils/constants.py index 56bec540ae2..6d22e2a6107 100644 --- a/src/poetry/utils/constants.py +++ b/src/poetry/utils/constants.py @@ -7,4 +7,18 @@ RETRY_AFTER_HEADER = "retry-after" # Server response codes to retry requests on. -STATUS_FORCELIST = [429, 500, 501, 502, 503, 504] +STATUS_FORCELIST = [ + 429, + 500, + 501, + 502, + 503, + 504, + # Cloudflare internal errors may indicate transient errors on the origin server + # https://github.com/cloudflare/cloudflare-docs/blob/9842ebbd3b3539ee64ac75daf766c091b90c7512/content/spectrum/reference/logs.md?plain=1#L41-L45 + 520, + 521, + 522, + 523, + 524, +] diff --git a/tests/utils/test_authenticator.py b/tests/utils/test_authenticator.py index 05c5490ac11..a26eb4881fc 100644 --- a/tests/utils/test_authenticator.py +++ b/tests/utils/test_authenticator.py @@ -282,6 +282,11 @@ def callback( (502, 5), (503, 5), (504, 5), + (520, 5), + (521, 5), + (522, 5), + (523, 5), + (524, 5), ], ) def test_authenticator_request_retries_on_status_code(