Skip to content

refactor(client)!: unify retry and attempt option naming - #2525

Merged
dinwwwh merged 4 commits into
mainfrom
claude/retry-attempt-naming-f23835
Nov 22, 2026
Merged

dinwwwh merged 4 commits into
mainfrom
claude/retry-attempt-naming-f23835

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Nov 21, 2026

Copy link
Copy Markdown
Member

Summary

Retry and attempt options in @orpc/client were spelled and counted inconsistently. This aligns them on one vocabulary before stable 2.0:

  • "retries" means additional tries after the first.
  • "attempts" means total tries, and is always plural.

Changes

  • RetryAfterLinkPlugin (breaking): condition is renamed to shouldRetry, matching RetryLinkPlugin. maxAttempts keeps its name, default (3) and meaning; its JSDoc now says the first request is counted.
  • WebSocket reconnect (breaking, new in v2): maxAttempt, maxTotalAttempt and the info field totalAttempt are renamed to maxAttempts, maxTotalAttempts and totalAttempts. attempt (the current attempt number) stays singular.
  • RetryLinkPlugin: no API change. The JSDoc for retry and for the callback's attempt now state how they count (retry: 3 allows up to 4 attempts in total).
  • Docs: plugins/retry.mdx, plugins/retry-after.mdx and adapters/websocket.mdx updated; the v1 migration guide gains a condition → shouldRetry entry.

Notes for reviewers

  • retry and maxAttempts were deliberately kept as in v1 to avoid breaking existing users; only their documentation changed.
  • Private fields in the WebSocket transport (reconnectMaxAttempt, totalAttempt) are left as-is to avoid conflicts with other in-flight changes to that file.
  • pnpm check and the client plugin, WebSocket adapter and retry e2e tests pass.

"retries" now always means additional tries after the first, and
"attempts" always means total tries and is always plural.

- RetryLinkPlugin: context `retry` renamed to `maxRetries`
- RetryAfterLinkPlugin: `condition` renamed to `shouldRetry`, and
  `maxAttempts` (total, default 3) replaced by `maxRetries`
  (excluding the first request, default 2)
- WebSocket reconnect: `maxAttempt`, `maxTotalAttempt` and
  `totalAttempt` renamed to `maxAttempts`, `maxTotalAttempts` and
  `totalAttempts`
Restore the v1 name instead of `maxRetries` to avoid a breaking change;
its JSDoc and docs still state that it excludes the first call.
Restore the v1 name and total-attempts counting instead of `maxRetries`;
its JSDoc and docs state that the first request is counted.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
orpc 1a07bac Commit Preview URL

Branch Preview URL
Nov 21 2026, 09:55 AM

@pkg-pr-new

pkg-pr-new Bot commented Nov 21, 2026

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@2525

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@2525

@orpc/bun

npm i https://pkg.pr.new/@orpc/bun@2525

@orpc/client

npm i https://pkg.pr.new/@orpc/client@2525

@orpc/cloudflare

npm i https://pkg.pr.new/@orpc/cloudflare@2525

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@2525

@orpc/effect

npm i https://pkg.pr.new/@orpc/effect@2525

@orpc/evlog

npm i https://pkg.pr.new/@orpc/evlog@2525

@orpc/hibernation

npm i https://pkg.pr.new/@orpc/hibernation@2525

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@2525

@orpc/experimental-lock

npm i https://pkg.pr.new/@orpc/experimental-lock@2525

@orpc/mcp

npm i https://pkg.pr.new/@orpc/mcp@2525

@orpc/msw

npm i https://pkg.pr.new/@orpc/msw@2525

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@2525

@orpc/next

npm i https://pkg.pr.new/@orpc/next@2525

@orpc/node

npm i https://pkg.pr.new/@orpc/node@2525

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@2525

@orpc/experimental-openapi-inference

npm i https://pkg.pr.new/@orpc/experimental-openapi-inference@2525

@orpc/opentelemetry

npm i https://pkg.pr.new/@orpc/opentelemetry@2525

@orpc/pinia-colada

npm i https://pkg.pr.new/@orpc/pinia-colada@2525

@orpc/pino

npm i https://pkg.pr.new/@orpc/pino@2525

@orpc/publisher

npm i https://pkg.pr.new/@orpc/publisher@2525

@orpc/ratelimit

npm i https://pkg.pr.new/@orpc/ratelimit@2525

@orpc/server

npm i https://pkg.pr.new/@orpc/server@2525

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@2525

@orpc/swr

npm i https://pkg.pr.new/@orpc/swr@2525

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@2525

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@2525

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@2525

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@2525

commit: 1a07bac

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Breaking Changes

    • WebSocket reconnect settings are now named maxAttempts and maxTotalAttempts; the connection attempt count is now totalAttempts.
    • The Retry After option condition is now shouldRetry.
  • Documentation

    • Clarified how retry limits count initial requests, retries, and successful connections, including examples of total attempts and retry delays.

The pull request clarifies retry-count behavior and renames retry-related options and attempt-count fields in the client. It updates tests, plugin documentation, WebSocket documentation, and the v1 migration guide to match.

Changes: Retry API updates

Layer / File(s) Summary
Retry count semantics
packages/client/src/plugins/retry.ts, apps/content/docs/plugins/retry.mdx
retry now counts retries after the initial call. The stopping condition uses that count, and the documentation describes the resulting attempt limit.
Retry After option and limit
packages/client/src/plugins/retry-after.ts, packages/client/src/plugins/retry-after.test.ts, apps/content/docs/plugins/retry-after.mdx, apps/content/docs/migrations/from-v1.mdx
The custom predicate option is renamed from condition to shouldRetry. The documentation states that maxAttempts includes the initial request and adds migration examples for the renamed plugin and option.
WebSocket reconnect options and attempt count
packages/client/src/adapters/websocket/transport.ts, packages/client/src/adapters/websocket/rpc-link.test.ts, apps/content/docs/adapters/websocket.mdx
The reconnect options become maxAttempts and maxTotalAttempts, and the callback field becomes totalAttempts. The tests and documentation use the updated names and attempt-count descriptions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related PRs

  • middleapi/orpc#265: Introduces the plugin-based client retry API, whose retry options are renamed in this pull request.
Merge Risk: Minimal · up to 1a07b

This change renames retry-related options and clarifies retry and attempt counting in the client and its docs. The renames are applied consistently and documented, and the author reports passing checks and tests. No concrete merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "refactor(client)!: unify retry and attempt option naming" matches the main change. The PR renames retry and attempt options in @orpc/client, including RetryAfterLinkPlugin's condition to sh…
Description check Passed The description states the purpose of the change: retry and attempt options in @orpc/client were named and counted inconsistently. It lists the concrete changes, including the condition to shouldRetry…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "refactor(client)!: unify retry and attempt option naming" matches the main change. The PR renames retry and attempt options in @orpc/client, including RetryAfterLinkPlugin's condition to shouldRetry and the WebSocket reconnect options to plural forms. The title is specific and uses a conventional commit prefix. It does not list every rename, which is acceptable.

Full details: Description check

Explanation

The description states the purpose of the change: retry and attempt options in @orpc/client were named and counted inconsistently. It lists the concrete changes, including the condition to shouldRetry rename, the WebSocket reconnect renames, the JSDoc updates, and the docs updates. It also gives reviewer notes on kept names and test status. It relates directly to the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f03409a1-5898-41f9-8420-4e9fa58d0db1
Commits

Reviewing files that changed from the base of the PR and between 65ed3c0 and 1a07bac.

Files selected for processing: 9

  • apps/content/docs/adapters/websocket.mdx
  • apps/content/docs/migrations/from-v1.mdx
  • apps/content/docs/plugins/retry-after.mdx
  • apps/content/docs/plugins/retry.mdx
  • packages/client/src/adapters/websocket/rpc-link.test.ts
  • packages/client/src/adapters/websocket/transport.ts
  • packages/client/src/plugins/retry-after.test.ts
  • packages/client/src/plugins/retry-after.ts
  • packages/client/src/plugins/retry.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Approach: sound — the rename is purely vocabulary alignment on a pre-2.0 public surface, and every documented counting rule was checked against the implementation.

Reviewed changes

  • RetryAfterLinkPlugin rename — condition → shouldRetry is complete (option, private field, call site, tests, both docs pages, migration guide); no other repo consumers passed condition.
  • maxAttempts semantics documented — the new JSDoc claim (3 = 2 retries, 1 = no retries) matches attemptCount++ followed by attemptCount >= maxAttempts.
  • WebSocket reconnect renames — maxAttempts / maxTotalAttempts / totalAttempts are propagated through the interface, constructor, info object, tests and adapters/websocket.mdx; no stale singular names remain in the repo, and the adapter is new in v2, so no migration entry is needed.
  • RetryLinkPlugin JSDoc — attempt as attempts made so far (first call included) and retry: 3 → up to 4 total attempts both hold for the plain and streamed (callNext({ error })) paths.
  • Migration guide — the new Retry After section correctly keeps the v1 class name RetryAfterPlugin in the v1 snippet; v1 did ship condition + maxAttempts, so the entry is accurate.

Local vitest run on retry-after.test.ts, retry.test.ts and adapters/websocket/rpc-link.test.ts passes (76 tests).

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 5 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 40 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing claude/retry-attempt-naming-f23835 (1a07bac) with main (65ed3c0)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@dinwwwh
dinwwwh merged commit f262ffe into main Nov 22, 2026
13 checks passed
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.

1 participant