Skip to content

ref(http): Retry Sentry API requests through @sentry/api 3's retry hook - #2542

Merged
BYK merged 2 commits into
mainfrom
feat/api-3-retry-hook
Nov 26, 2026
Merged

BYK merged 2 commits into
mainfrom
feat/api-3-retry-hook

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Bumps @sentry/api to 3.0.0 and moves the CLI and MCP retries onto the transport's new retry hook, added in getsentry/sentry#132687.

What changes

  • toolkit-core: withSentryRetry and TRANSPORT_SENDS_ONCE are replaced by sentryRetry(options): TransportRetry. It builds the hook on @sentry/http's fetchWithRetry, using SENTRY_RETRYABLE_STATUSES and @sentry/api's parseRetryDelayMs. SentryRetryOptions takes policy, isRetryableError, and an onRetry that also gets the retried request's method and URL.
  • CLI and MCP: both pass retry: sentryRetry({ policy }) to createApiTransport instead of wrapping transport.request. The transport now runs the hook after the cache lookup and the credential's prepare. A retried request looks up the cache and the credential once, and it gets one host span instead of one per attempt. Each attempt still has its own timeout, body buffering, redirect checks, and 401 refresh, and the refresh doesn't count as a retry.
  • Idempotency: the hook gets idempotent from the transport, which already combines the per-request flag with the operation catalog (isIdempotent). So the wrapper's separate isIdempotent option goes away.
  • CLI isRetryableError: the TimeoutError case is gone. An attempt now throws the transport's ApiTimeoutError, which isn't a CliError, so it still retries. errors.timeout maps the final timeout to TimeoutError once, after the hook gives up.
  • MCP issue-event read: 3.0.0 types event_id as a string, so the cast for 32-character event IDs is removed. Without it, lint fails with an unnecessary-assertion error.
  • pnpm-workspace.yaml: the catalog entry and the minimumReleaseAgeExclude entry move to @sentry/api@3.0.0.

Also picked up from 2.16.0

The bump from 2.15.0 includes getsentry/sentry#131779, which sends and reads Objectstore batches as FormData. Each operation is a JSON part named by its index, and an insert's bytes go in <index>.payload. The CLI's snapshot uploads use that batch client, so their wire format changes with this PR. The CLI's objectstore test fixtures now build responses in that format.

@sentry/http needs no new export: fetchWithRetry(send, options) already fits the hook.

via @BYK.

--

View Session [Sentry]

@sentry/api 3.0.0 replaces the transport's `retry` policy with a hook
the transport calls once per request, after the cache lookup and the
credential's `prepare`. toolkit-core now builds that hook on
@sentry/http's `fetchWithRetry` as `sentryRetry`, and the CLI and MCP
pass it to `createApiTransport` instead of wrapping `transport.request`
with `withSentryRetry`. So a retried request looks up the cache and the
credential once, not once per attempt. `TRANSPORT_SENDS_ONCE` goes away.

The CLI's `isRetryableError` drops its `TimeoutError` case: an attempt
now throws the transport's `ApiTimeoutError`, and `errors.timeout` maps
it to `TimeoutError` once, after the hook gives up.

The bump also types `event_id` as a string, so the MCP client's cast
for 32-character event IDs is no longer needed.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Nov 26, 2026 7:49pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 26, 2026 7:49pm UTC

Request Review

@sentry/api 3.0.0 includes getsentry/sentry#131779, which sends and
reads Objectstore batches as FormData: one JSON part per operation,
named by its index, with an insert's bytes in `<index>.payload`. The
CLI's objectstore tests still built responses with the old
`x-sn-batch-operation-*` part headers, which the new parser rejects.
@BYK
BYK marked this pull request as ready for review November 26, 2026 22:23
@BYK
BYK requested a review from a team as a code owner November 26, 2026 22:23
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 26, 2026
@BYK
BYK merged commit c5695e6 into main Nov 26, 2026
49 checks passed
@BYK
BYK deleted the feat/api-3-retry-hook branch November 26, 2026 22:24

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — 3c1ffdf9 Deployed Nov 26, 2026 by vercel[bot]
Preview – sentry-local — 3c1ffdf9 Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant