Skip to content

Retry on Net::HTTPFatalError#1811

Merged
mbroshi-stripe merged 1 commit intomasterfrom
mbroshi/retry-fatal-error
Mar 10, 2026
Merged

Retry on Net::HTTPFatalError#1811
mbroshi-stripe merged 1 commit intomasterfrom
mbroshi/retry-fatal-error

Conversation

@mbroshi-stripe
Copy link
Copy Markdown
Contributor

@mbroshi-stripe mbroshi-stripe commented Mar 10, 2026

Why?

Ruby's net/http can raise Net::HTTPFatalError for 5xx responses (link) before stripe-ruby converts the response into a Stripe::StripeError. Because our retry logic only retried known network exceptions and Stripe::StripeError instances, these transient 5xx failures were not retried.

This change makes retry behavior consistent for that code path so temporary 5xx failures surfaced as Net::HTTPFatalError are retried like other transient server-side failures.

What?

  • treat Net::HTTPFatalError as retryable in APIRequestor.should_retry?
  • map Net::HTTPFatalError through NETWORK_ERROR_MESSAGES_MAP so exhausted retries raise Stripe::APIConnectionError
  • add tests covering both the retry classification and persistent-failure retry behavior

Changelog

  • Fixes a bug where Net::HTTPFatalError errors were being thrown and not retried (unlike other 5xx responses from the Stripe API)

@mbroshi-stripe mbroshi-stripe marked this pull request as ready for review March 10, 2026 20:20
@mbroshi-stripe mbroshi-stripe requested a review from a team as a code owner March 10, 2026 20:20
@mbroshi-stripe mbroshi-stripe requested review from xavdid-stripe and removed request for a team March 10, 2026 20:20
Copy link
Copy Markdown
Contributor

@xavdid-stripe xavdid-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@mbroshi-stripe mbroshi-stripe merged commit 1155526 into master Mar 10, 2026
15 checks passed
@mbroshi-stripe mbroshi-stripe deleted the mbroshi/retry-fatal-error branch March 10, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants