-
Notifications
You must be signed in to change notification settings - Fork 627
[SDK] Add caching and timeout for fetching capabilities #8485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDK] Add caching and timeout for fetching capabilities #8485
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 36aeb50 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughAdds a caching layer and a 5s timeout for capabilities fetching in the step executor, improves error handling for failed transaction receipts, logs errors in calls-receipt polling, and allows chainId filtering when requesting injected wallet capabilities. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
727-763: Well-structured caching and timeout implementation.The logic is sound:
- Cache lookup correctly checks
!== undefinedto handlefalsevalues- 5-second timeout via
Promise.raceprevents hanging on slow/unresponsive wallets- Intentionally not caching failures allows retries to succeed later
One consideration: the module-level cache is unbounded. For typical usage this is fine, but in long-running apps with many accounts/chains, entries accumulate indefinitely.
If cache growth becomes a concern, consider using an LRU cache or adding a TTL:
-const supportsAtomicCache = new Map<string, boolean>(); +const supportsAtomicCache = new Map<string, { value: boolean; timestamp: number }>(); +const CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutesThen check
Date.now() - cached.timestamp < CACHE_TTL_MSbefore returning cached values.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
.changeset/twelve-grapes-drop.md(1 hunks)packages/thirdweb/src/react/core/hooks/useStepExecutor.ts(2 hunks)packages/thirdweb/src/wallets/eip5792/wait-for-calls-receipt.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each TypeScript file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes in TypeScript
Avoidanyandunknownin TypeScript unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.) in TypeScript
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity and testability
Re-use shared types from @/types or local types.ts barrel exports
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics whenever possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic in TypeScript files; avoid restating TypeScript types and signatures in prose
Files:
packages/thirdweb/src/wallets/eip5792/wait-for-calls-receipt.tspackages/thirdweb/src/react/core/hooks/useStepExecutor.ts
packages/thirdweb/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
packages/thirdweb/src/**/*.{ts,tsx}: Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose
Load heavy dependencies inside async paths to keep initial bundle lean (e.g.const { jsPDF } = await import("jspdf");)Lazy-load heavy dependencies inside async paths to keep the initial bundle lean (e.g., const { jsPDF } = await import('jspdf');)
Files:
packages/thirdweb/src/wallets/eip5792/wait-for-calls-receipt.tspackages/thirdweb/src/react/core/hooks/useStepExecutor.ts
**/*.{js,jsx,ts,tsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Biome governs formatting and linting; its rules live in biome.json. Run
pnpm fix&pnpm lintbefore committing, ensure there are no linting errors
Files:
packages/thirdweb/src/wallets/eip5792/wait-for-calls-receipt.tspackages/thirdweb/src/react/core/hooks/useStepExecutor.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Lazy-import optional features; avoid top-level side-effects
Files:
packages/thirdweb/src/wallets/eip5792/wait-for-calls-receipt.tspackages/thirdweb/src/react/core/hooks/useStepExecutor.ts
🧬 Code graph analysis (1)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
packages/thirdweb/src/bridge/types/Errors.ts (1)
ApiError(11-36)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Vercel Agent Review
- GitHub Check: Size
- GitHub Check: Unit Tests
🔇 Additional comments (3)
.changeset/twelve-grapes-drop.md (1)
1-5: LGTM!Changeset correctly describes the feature and patch version bump is appropriate for this non-breaking enhancement.
packages/thirdweb/src/wallets/eip5792/wait-for-calls-receipt.ts (1)
97-100: LGTM!Good improvement to surface errors for debugging while preserving the retry behavior. The comment clearly explains the intent.
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
386-394: LGTM!Properly handles transaction failure by throwing a typed
ApiErrorwith a user-friendly message. This ensures failures are propagated through the existing error handling flow.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8485 +/- ##
==========================================
- Coverage 54.73% 54.70% -0.03%
==========================================
Files 920 920
Lines 61013 61046 +33
Branches 4145 4143 -2
==========================================
+ Hits 33395 33398 +3
- Misses 27516 27546 +30
Partials 102 102
🚀 New features to boost your workflow:
|
size-limit report 📦
|
80503f5 to
36aeb50
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
727-764: Consider logging timeout events for debugging.The caching implementation correctly avoids caching timeout/error cases (line 761), which prevents persistent false negatives. However, when capabilities fetch times out, returning
falsemeans the wallet will fall back to non-atomic transactions even if atomic batching is actually supported.Consider adding debug logging when timeouts occur to help diagnose slow capability checks:
} catch (error) { - // Timeout or error fetching capabilities, assume not supported, but dont cache the result + // Timeout or error fetching capabilities, assume not supported, but dont cache the result + console.debug(`Failed to fetch capabilities for ${account.address} on chain ${chainId}:`, error); return false; }This will help identify wallets with slow capability responses during development and testing.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
.changeset/twelve-grapes-drop.md(1 hunks)packages/thirdweb/src/react/core/hooks/useStepExecutor.ts(2 hunks)packages/thirdweb/src/wallets/eip5792/wait-for-calls-receipt.ts(1 hunks)packages/thirdweb/src/wallets/injected/index.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/thirdweb/src/wallets/eip5792/wait-for-calls-receipt.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each TypeScript file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes in TypeScript
Avoidanyandunknownin TypeScript unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.) in TypeScript
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity and testability
Re-use shared types from @/types or local types.ts barrel exports
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics whenever possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic in TypeScript files; avoid restating TypeScript types and signatures in prose
Files:
packages/thirdweb/src/wallets/injected/index.tspackages/thirdweb/src/react/core/hooks/useStepExecutor.ts
packages/thirdweb/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
packages/thirdweb/src/**/*.{ts,tsx}: Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose
Load heavy dependencies inside async paths to keep initial bundle lean (e.g.const { jsPDF } = await import("jspdf");)Lazy-load heavy dependencies inside async paths to keep the initial bundle lean (e.g., const { jsPDF } = await import('jspdf');)
Files:
packages/thirdweb/src/wallets/injected/index.tspackages/thirdweb/src/react/core/hooks/useStepExecutor.ts
**/*.{js,jsx,ts,tsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Biome governs formatting and linting; its rules live in biome.json. Run
pnpm fix&pnpm lintbefore committing, ensure there are no linting errors
Files:
packages/thirdweb/src/wallets/injected/index.tspackages/thirdweb/src/react/core/hooks/useStepExecutor.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Lazy-import optional features; avoid top-level side-effects
Files:
packages/thirdweb/src/wallets/injected/index.tspackages/thirdweb/src/react/core/hooks/useStepExecutor.ts
🧬 Code graph analysis (1)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
packages/thirdweb/src/bridge/types/Errors.ts (1)
ApiError(11-36)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Size
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: Unit Tests
- GitHub Check: Lint Packages
- GitHub Check: Build Packages
- GitHub Check: Vercel Agent Review
- GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
.changeset/twelve-grapes-drop.md (1)
1-5: LGTM!The changeset correctly documents the patch release with a clear description of the feature.
packages/thirdweb/src/wallets/injected/index.ts (1)
381-384: LGTM!The chainId filter implementation correctly wraps the hex-encoded chainId in an array format as expected by the
wallet_getCapabilitiesRPC method, and properly handles the optional parameter case.packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
387-394: LGTM!The error handling correctly throws an ApiError when the transaction fails, with a user-friendly message suggesting alternative actions.

PR-Codex overview
This PR introduces caching and timeout mechanisms for fetching wallet capabilities, improving error handling and performance in the
thirdwebpackage.Detailed summary
supportsAtomicresults insupportAtomicCache.waitForCallsReceiptby logging errors.wallet_getCapabilitiesto include an optionalchainIdFilter.ApiErrorfor transaction failures inuseStepExecutor.Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.