Repository navigation
feat(client): add retryDelayMs-option to retryLink - #6694
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request introduces an optional property Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant R as RetryLink
participant T as Timer
C->>R: Execute operation
R-->>C: Operation fails
R->>R: Compute delay using retryDelayMs(attempt) or default 0
R->>T: setTimeout(delay)
T-->>R: Timeout complete
R->>C: Retry operation
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🧰 Additional context used🧬 Code Graph Analysis (1)packages/tests/server/links.test.ts (5)
⏰ Context from checks skipped due to timeout of 90000ms (20)
🔇 Additional comments (11)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@rynobax is attempting to deploy a commit to the trpc Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/client/src/links/retryLink.ts (1)
77-84: Retry delay implementation looks good but has a minor optimization opportunity.The implementation correctly handles the optional retry delay with a good fallback to 0 when not provided. However, there's a small opportunity to make the code more DRY by avoiding the duplication of
attempt(attempts + 1).- const delay = opts.retryDelay?.(attempts) ?? 0; - if (delay) { - setTimeout(() => { - attempt(attempts + 1); - }, delay); - } else { - attempt(attempts + 1); - } + const delay = opts.retryDelay?.(attempts) ?? 0; + if (delay) { + setTimeout(() => attempt(attempts + 1), delay); + } else { + attempt(attempts + 1); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/client/src/links/retryLink.ts(2 hunks)www/docs/client/links/retryLink.md(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (20)
- GitHub Check: E2E-tests (next-minimal-starter)
- GitHub Check: E2E-tests (vercel-edge-runtime)
- GitHub Check: E2E-tests (cloudflare-workers)
- GitHub Check: Release using pkg.pr.new
- GitHub Check: E2E-tests (.experimental/next-app-dir)
- GitHub Check: E2E-tests (minimal-react)
- GitHub Check: E2E-tests (fastify-server)
- GitHub Check: E2E-tests (express-minimal)
- GitHub Check: E2E-tests (.test/diagnostics-big-router)
- GitHub Check: e2e-legacy-node (next-prisma-todomvc, 18.x)
- GitHub Check: e2e-legacy-node (next-prisma-starter, 20.x)
- GitHub Check: e2e-legacy-node (next-prisma-todomvc, 20.x)
- GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 20.x)
- GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 18.x)
- GitHub Check: e2e-legacy-node (next-prisma-starter, 18.x)
- GitHub Check: Test a monorepo using built declaration files
- GitHub Check: E2E-tests (Bun) (bun, ubuntu-latest)
- GitHub Check: E2E-tests (Deno) (deno-deploy)
- GitHub Check: test
- GitHub Check: Lint and auto-fix
🔇 Additional comments (3)
packages/client/src/links/retryLink.ts (1)
15-18: Well-documented addition to RetryLinkOptions interface.The
retryDelayproperty is properly typed as an optional function with clear documentation explaining its purpose and default behavior.www/docs/client/links/retryLink.md (2)
40-41: Great example of exponential backoff with a sensible maximum cap.The provided example demonstrates an excellent implementation of an exponential backoff strategy, which is a best practice for retries. The maximum cap of 30 seconds prevents excessive wait times for users while still allowing for proper backing off.
65-68: Documentation matches implementation and is clear.The documentation for the
retryDelayproperty is consistent with the implementation in the source code and clearly explains its purpose and default behavior.
@trpc/client
@trpc/next
@trpc/server
@trpc/react-query
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
www/docs/client/links/retryLink.md (1)
65-68: Review the newretryDelayproperty in the interface.
The addition of the optional propertyretryDelay?: (attempt: number) => numberis well documented, explaining that it defaults to 0 if not provided. For improved clarity, consider including a brief note or example in the documentation to illustrate its usage and behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
www/docs/client/links/retryLink.md(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Lint and auto-fix
🔇 Additional comments (1)
www/docs/client/links/retryLink.md (1)
40-41: Verify theretryDelayfunction behavior in the usage example.
The function correctly employs exponential backoff by doubling delay per attempt and capping at 30 seconds. Please verify that the initial delay (when attempt index is 0) meets developer expectations (1 second).
KATT
left a comment
There was a problem hiding this comment.
Added tests and fixed an edge-case when unsubscribing during the delay
retryDelayMs-option to retryLink (#6694)
retryDelayMs-option to retryLink (#6694)retryDelayMs-option to retryLink
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
Addresses #6425
🎯 Changes
Add a
retryDelayoption to RetryLink. Right now it defaults to immediately retrying on failure, this allows introducing a delay.IMO this should have a reasonable default (what i provided in the docs is the tanstack query default). Since that would be a breaking change, I think it makes sense to do it in a follow up pr.
✅ Checklist
Summary by CodeRabbit
New Features
Bug Fixes
Documentation