Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/contributing/api-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ Retries are:
out than the single-wait cap fails at once with an `ApiRateLimitError` whose
`retryAfterMs` and user message say when to retry.
- **Abortable** — aborting the request's `signal` ends the wait.
- **Fail-fast otherwise** — network and configuration errors are not retried.
- **Network failures retry for idempotent requests** — when `fetch` itself
fails (DNS, connection refused or reset, socket timeout), only GET, HEAD,
and OPTIONS retry, since a write may already have reached Sentry.
- **Fail-fast otherwise** — configuration errors (such as a malformed token)
are not retried.
A rate-limited tool call returns a **Rate Limited** message with the retry
time, not an input error.
- **Bypassed by `allowStatuses`** — a status the caller opts into is returned
Expand All @@ -289,6 +293,12 @@ Retries are:
Callers and tools need no changes: a retried request either resolves normally or
throws the same error it would have thrown without retries.

The CLI's transport (`packages/cli/src/lib/sentry-client.ts`) follows the same
shared rule. Only the caps differ (`RETRY_POLICY`): the hosted MCP keeps its
total wait short so a Workers request isn't held open, while the CLI can wait
longer. The CLI also applies its own per-request timeout, which counts as a
network failure.

## Best Practices

1. **Always use context helper** when in tools/prompts
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/script/generate-api-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export type { ApiEndpoint } from "../src/lib/api-schema.js";

import type { ApiEndpoint } from "../src/lib/api-schema.js";
import type { IdempotentOperation } from "../src/lib/idempotent-operations.js";
import { isRetryableMethod } from "../src/lib/retry-policy.js";
import { isIdempotentRequest } from "@sentry/toolkit-core/api-retry";

// ---------------------------------------------------------------------------
// OpenAPI Types (minimal subset we need)
Expand Down Expand Up @@ -244,7 +244,7 @@ console.log(
// Safe methods already retry, so only writes need listing; that keeps the
// file the CLI loads on every request tiny.
const idempotentOperations: IdempotentOperation[] = operations
.filter((op) => op.idempotent && !isRetryableMethod(op.method))
.filter((op) => op.idempotent && !isIdempotentRequest(op.method))
.map((op) => ({ method: op.method, path: op.path }))
.sort(
(a, b) => a.path.localeCompare(b.path) || a.method.localeCompare(b.method),
Expand Down
165 changes: 0 additions & 165 deletions packages/cli/src/lib/retry-policy.ts

This file was deleted.

Loading
Loading