Jump to solution
Verify

The Fix

pip install stripe==14.4.0a2

Based on closed stripe/stripe-python issue #1427 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -19,6 +19,7 @@ from stripe import StripeClient from stripe.events import UnknownEventNotification +from stripe.events import ALL_EVENT_NOTIFICATIONS from flask import Flask, request, jsonify
repro.py
from __future__ import annotations from typing import TYPE_CHECKING, Protocol, Type from django.conf import settings if TYPE_CHECKING: import stripe class StripeTestHelpers(Protocol): TestClock: Type[stripe.test_helpers.TestClock] class StripeBilling(Protocol): Session: Type[stripe.billing_portal.Session] class StripeModule(Protocol): billing_portal: StripeBilling test_helpers: StripeTestHelpers Customer: Type[stripe.Customer] Invoice: Type[stripe.Invoice] CardError: Type[stripe.CardError] InvalidRequestError: Type[stripe.InvalidRequestError] AuthenticationError: Type[stripe.AuthenticationError] APIConnectionError: Type[stripe.APIConnectionError] StripeError: Type[stripe.StripeError] Subscription: Type[stripe.Subscription] Token: Type[stripe.Token] Price: Type[stripe.Price] BalanceTransaction: Type[stripe.BalanceTransaction] PaymentMethod: Type[stripe.PaymentMethod] def get_stripe_client() -> StripeModule: import stripe stripe.api_key = settings.STRIPE_SECRET_KEY stripe.api_version = "2019-12-03" return stripe
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install stripe==14.4.0a2\nWhen NOT to use: This fix is not suitable for environments where import speed is not critical.\n\n

Why This Fix Works in Production

  • Trigger: from __future__ import annotations
  • Mechanism: The library's import process was inefficient, causing significant delays during startup
  • Why the fix works: Dramatically improves import speeds and memory usage by lazily loading most imports, addressing the performance issues raised in issue #1427. (first fixed release: 14.4.0a2).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.13 in real deployments (not just unit tests).
  • The library's import process was inefficient, causing significant delays during startup
  • Surfaces as: from __future__ import annotations

Proof / Evidence

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“Amazing! The only reason it's not ready for review yet is that i'm actually making it even faster 😅 Glad to hear it's working as…”
@xavdid-stripe · 2025-10-16 · confirmation · source
“We released a bunch of performance improvements in v13.1.0 which came out this week”
@xavdid-stripe · 2025-10-30 · confirmation · source
“Over 50% of start time for our app is by the stripe SDK, and like others have observed, RAM usage has crept up as the…”
@rushilsrivastava · 2025-04-04 · source
“Upgraded from an old version and got a major increase of memory usage. Tried several versions from major 9 to 12. None seemed to be…”
@bjornhol · 2025-06-12 · source

Failure Signature (Search String)

  • from __future__ import annotations

Error Message

Stack trace
error.txt
Error Message ------------- from __future__ import annotations from typing import TYPE_CHECKING, Protocol, Type from django.conf import settings if TYPE_CHECKING: import stripe class StripeTestHelpers(Protocol): TestClock: Type[stripe.test_helpers.TestClock] class StripeBilling(Protocol): Session: Type[stripe.billing_portal.Session] class StripeModule(Protocol): billing_portal: StripeBilling test_helpers: StripeTestHelpers Customer: Type[stripe.Customer] Invoice: Type[stripe.Invoice] CardError: Type[stripe.CardError] InvalidRequestError: Type[stripe.InvalidRequestError] AuthenticationError: Type[stripe.AuthenticationError] APIConnectionError: Type[stripe.APIConnectionError] StripeError: Type[stripe.StripeError] Subscription: Type[stripe.Subscription] Token: Type[stripe.Token] Price: Type[stripe.Price] BalanceTransaction: Type[stripe.BalanceTransaction] PaymentMethod: Type[stripe.PaymentMethod] def get_stripe_client() -> StripeModule: import stripe stripe.api_key = settings.STRIPE_SECRET_KEY stripe.api_version = "2019-12-03" return stripe

Minimal Reproduction

repro.py
from __future__ import annotations from typing import TYPE_CHECKING, Protocol, Type from django.conf import settings if TYPE_CHECKING: import stripe class StripeTestHelpers(Protocol): TestClock: Type[stripe.test_helpers.TestClock] class StripeBilling(Protocol): Session: Type[stripe.billing_portal.Session] class StripeModule(Protocol): billing_portal: StripeBilling test_helpers: StripeTestHelpers Customer: Type[stripe.Customer] Invoice: Type[stripe.Invoice] CardError: Type[stripe.CardError] InvalidRequestError: Type[stripe.InvalidRequestError] AuthenticationError: Type[stripe.AuthenticationError] APIConnectionError: Type[stripe.APIConnectionError] StripeError: Type[stripe.StripeError] Subscription: Type[stripe.Subscription] Token: Type[stripe.Token] Price: Type[stripe.Price] BalanceTransaction: Type[stripe.BalanceTransaction] PaymentMethod: Type[stripe.PaymentMethod] def get_stripe_client() -> StripeModule: import stripe stripe.api_key = settings.STRIPE_SECRET_KEY stripe.api_version = "2019-12-03" return stripe

Environment

  • Python: 3.13

What Broke

Importing the library resulted in a 500ms delay, impacting serverless cold start performance.

Why It Broke

The library's import process was inefficient, causing significant delays during startup

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install stripe==14.4.0a2

When NOT to use: This fix is not suitable for environments where import speed is not critical.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/stripe/stripe-python/pull/1645

First fixed release: 14.4.0a2

Last verified: 2026-02-08. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix is not suitable for environments where import speed is not critical.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
  • Pin production dependencies and upgrade only with a reproducible test that hits the failing path.

Version Compatibility Table

VersionStatus
14.4.0a2 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.