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 = {