From 5d9480ee34f1e47eab8fd3ba03b3b748f1a18d91 Mon Sep 17 00:00:00 2001 From: gregfromstl Date: Mon, 15 Sep 2025 09:35:02 -0700 Subject: [PATCH] fix: add brief pause after onramp 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/floppy-clocks-wave.md | 5 +++++ packages/thirdweb/src/react/core/hooks/useStepExecutor.ts | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/floppy-clocks-wave.md diff --git a/.changeset/floppy-clocks-wave.md b/.changeset/floppy-clocks-wave.md new file mode 100644 index 00000000000..4daa617ff07 --- /dev/null +++ b/.changeset/floppy-clocks-wave.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Prevents incorrect failures in widget onramps. diff --git a/packages/thirdweb/src/react/core/hooks/useStepExecutor.ts b/packages/thirdweb/src/react/core/hooks/useStepExecutor.ts index a568bd376cd..c2e7e7083a3 100644 --- a/packages/thirdweb/src/react/core/hooks/useStepExecutor.ts +++ b/packages/thirdweb/src/react/core/hooks/useStepExecutor.ts @@ -372,6 +372,11 @@ export function useStepExecutor( const status = statusResult.status; if (status === "COMPLETED") { + /* + * The occasional race condition can happen where the onramp provider gives us completed status before the token balance has updated in our RPC. + * We add this pause so the simulation doesn't fail on the next step. + */ + await new Promise((resolve) => setTimeout(resolve, 2000)); setOnrampStatus("completed"); // Add type field for discriminated union const typedStatusResult = {