-
Notifications
You must be signed in to change notification settings - Fork 588
Fix: Add brief pause after onramp #8052
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
Conversation
Adds a brief pause after we receive a COMPLETED onramp status. This ensures balance is the latest value in our RPC and any subsequent transactions do not fail on simulation.
🦋 Changeset detectedLatest commit: 5d9480e The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughIntroduces a changeset entry for the thirdweb package (patch) and updates useStepExecutor to insert a 2-second delay after detecting onramp completion before marking it completed, with a comment explaining an RPC balance update race condition. No public API changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Widget
participant useStepExecutor
participant OnrampProvider as Onramp Provider
participant RPC as RPC/Balance
User->>Widget: Initiate onramp
Widget->>useStepExecutor: Start onramp flow
useStepExecutor->>OnrampProvider: Poll onramp status
OnrampProvider-->>useStepExecutor: Status = COMPLETED
note over useStepExecutor: New behavior: wait ~2s to avoid race with RPC balance updates
useStepExecutor-->>useStepExecutor: Delay 2000ms
useStepExecutor->>RPC: (Subsequent) Balance reflects funds
useStepExecutor-->>Widget: Mark onramp completed + record status
Widget-->>User: Show completion
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. 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. |
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (1)
388-391
: Break out on FAILED to avoid infinite polling loop.When onramp reports FAILED, we set state but never exit the poller; it will loop forever. Align with tx polling which throws on failure.
- } else if (status === "FAILED") { - setOnrampStatus("failed"); - } + } else if (status === "FAILED") { + setOnrampStatus("failed"); + throw new Error("Onramp failed"); + }
🧹 Nitpick comments (3)
.changeset/floppy-clocks-wave.md (1)
1-5
: Changeset added correctly; consider a clearer, action-oriented description.Suggestion: “Onramp: add 2s post‑completion pause to avoid RPC balance race causing simulation failures.” Improves changelog usefulness.
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts (2)
375-379
: Make the 2s pause abortable (respect cancel) and configurable.Current timeout can’t be canceled mid-wait; honor the provided AbortSignal and avoid hard-coding.
Apply within this range:
- await new Promise((resolve) => setTimeout(resolve, 2000)); + await abortableDelay(2000, abortSignal);Add helper (outside this range, near poller util or top-level in this file):
function abortableDelay(ms: number, signal: AbortSignal): Promise<void> { return new Promise((resolve, reject) => { const t = setTimeout(resolve, ms); const onAbort = () => { clearTimeout(t); signal.removeEventListener("abort", onAbort); reject(new Error("Aborted")); }; signal.addEventListener("abort", onAbort, { once: true }); }); }Optional: surface
postOnrampDelayMs?: number
in StepExecutorOptions with default 2000.
240-241
: DRY the identical “RPC catch-up” sleeps into a shared utility.Both approval/fee path and onramp use a 2s delay. Centralize via
abortableDelay(ms, signal)
for consistency and cancellation support.Also applies to: 375-379
📜 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 (2)
.changeset/floppy-clocks-wave.md
(1 hunks)packages/thirdweb/src/react/core/hooks/useStepExecutor.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 file to one stateless, single-responsibility function for clarity
Re-use shared types from@/types
or localtypes.ts
barrels
Prefer type aliases over interface except for nominal shapes
Avoidany
andunknown
unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial
,Pick
, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}
: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/types
where applicable
Prefertype
aliases overinterface
except for nominal shapes
Avoidany
andunknown
unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts
packages/thirdweb/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
packages/thirdweb/**/*.{ts,tsx}
: Every public symbol must have comprehensive TSDoc with at least one compiling@example
and a custom tag (@beta
,@internal
,@experimental
, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g.,const { jsPDF } = await import("jspdf")
)
Files:
packages/thirdweb/src/react/core/hooks/useStepExecutor.ts
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
.changeset/*.md
: Each change inpackages/*
must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API
Files:
.changeset/floppy-clocks-wave.md
⏰ 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). (8)
- GitHub Check: Size
- GitHub Check: Unit Tests
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Lint Packages
- GitHub Check: Build Packages
- GitHub Check: Analyze (javascript)
size-limit report 📦
|
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #8052 +/- ##
==========================================
- Coverage 56.53% 56.53% -0.01%
==========================================
Files 904 904
Lines 58864 58865 +1
Branches 4166 4166
==========================================
Hits 33280 33280
- Misses 25478 25479 +1
Partials 106 106
🚀 New features to boost your workflow:
|
Adds a brief pause after we receive a COMPLETED onramp status. This ensures balance is the latest value in our RPC and any subsequent transactions do not fail on simulation.
PR-Codex overview
This PR addresses a potential race condition in the
thirdweb
widget onramps, ensuring that the simulation does not fail due to timing issues with token balance updates.Detailed summary
setTimeout
inuseStepExecutor.ts
to handle race conditions where the onramp provider reports a completed status before the token balance updates.typedStatusResult
object for a discriminated union.Summary by CodeRabbit
Bug Fixes
Chores