fix(provider): time out and retry Mollie 429 and 409 responses #164

Sammanfogat
supernaut sammanfogade 1 incheckning från fix/mollie-retry in i main 2026-10-12 18:44:43 +00:00
Ägare

What

Every Mollie call now has a 10 s timeout. A 429 is retried with backoff. A 409 (same idempotency key still in flight) is retried on keyed writes.

Why

The SDK retries only 5xx. A 429 during startCheckout failed the customer's checkout. One 429 aborted a reconciliation pass. A stalled connection held a webhook handler, and Mollie cuts webhook calls off after 15 s.

How

  • New src/provider/mollie-retry.ts wraps the SDK client once, in the MollieProvider constructor. No call site changes.
  • Timeout: 10 s per call.
  • Retry: up to 3 attempts, 1 s then 2 s backoff.
  • Reads (get, list, page) retry on 429.
  • Writes retry only when the call carries our own idempotencyKey, and every attempt sends the same key. They retry on 429 and 409.
  • Writes without a key (subscription update and cancel) are never retried. The SDK would mint a new key per attempt.
  • listPayments and listChargebacks page with page() and nextPage() instead of iterate(). The iterator cannot resume after a failed fetch. Each next-page fetch is retried.

Limits

  • The SDK does not expose the Retry-After header or an abort signal. Backoff is fixed, and a timed-out request is abandoned, not cancelled.
  • A timeout is not retried.

Tested

  • New src/provider/mollie-retry.test.ts: 429 then success, attempt cap, same key on every write attempt, no retry for unkeyed writes, 409 only on keyed writes, other errors not retried, timeout, this binding.
  • src/provider/mollie.test.ts: listings now use page, plus a multi-page case.
  • pnpm test, pnpm lint, pnpm typecheck pass.

Closes #148
Closes #86

## What Every Mollie call now has a 10 s timeout. A 429 is retried with backoff. A 409 (same idempotency key still in flight) is retried on keyed writes. ## Why The SDK retries only 5xx. A 429 during `startCheckout` failed the customer's checkout. One 429 aborted a reconciliation pass. A stalled connection held a webhook handler, and Mollie cuts webhook calls off after 15 s. ## How - New `src/provider/mollie-retry.ts` wraps the SDK client once, in the `MollieProvider` constructor. No call site changes. - Timeout: 10 s per call. - Retry: up to 3 attempts, 1 s then 2 s backoff. - Reads (`get`, `list`, `page`) retry on 429. - Writes retry only when the call carries our own `idempotencyKey`, and every attempt sends the same key. They retry on 429 and 409. - Writes without a key (subscription update and cancel) are never retried. The SDK would mint a new key per attempt. - `listPayments` and `listChargebacks` page with `page()` and `nextPage()` instead of `iterate()`. The iterator cannot resume after a failed fetch. Each next-page fetch is retried. ## Limits - The SDK does not expose the `Retry-After` header or an abort signal. Backoff is fixed, and a timed-out request is abandoned, not cancelled. - A timeout is not retried. ## Tested - New `src/provider/mollie-retry.test.ts`: 429 then success, attempt cap, same key on every write attempt, no retry for unkeyed writes, 409 only on keyed writes, other errors not retried, timeout, `this` binding. - `src/provider/mollie.test.ts`: listings now use `page`, plus a multi-page case. - `pnpm test`, `pnpm lint`, `pnpm typecheck` pass. Closes #148 Closes #86
supernaut lade till 1 incheckning 2026-10-12 18:32:41 +00:00
fix(provider): time out and retry Mollie 429 and 409 responses (#148, #86)
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m6s
4cfda5737b
supernaut sammanfogade incheckning 5f7840bc80 till main 2026-10-12 18:44:43 +00:00
supernaut tog bort grenen fix/mollie-retry 2026-10-12 18:44:43 +00:00
Logga in för att delta i denna konversation.
Inga granskare
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-payment!164
Ingen beskrivning angiven.