File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
packages/clerk-js/src/core/resources Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @clerk/clerk-js ' : patch
3+ ---
4+
5+ Retry checkout confirmation if there is another checkout in progress
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
1313 __experimental_CommercePlan ,
1414 __experimental_CommerceSubscription ,
1515 BaseResource ,
16+ isClerkAPIResponseError ,
1617} from './internal' ;
1718
1819export class __experimental_CommerceCheckout extends BaseResource implements __experimental_CommerceCheckoutResource {
@@ -75,8 +76,16 @@ export class __experimental_CommerceCheckout extends BaseResource implements __e
7576 initialDelay : 2 * 1_000 ,
7677 jitter : false ,
7778 shouldRetry ( error : any , iterations : number ) {
79+ if ( ! isClerkAPIResponseError ( error ) || iterations >= 4 ) {
80+ return false ;
81+ }
82+
7883 const status = error ?. status ;
79- return ! ! status && status >= 500 && iterations <= 4 ;
84+ const isServerError = status >= 500 ;
85+ const checkoutAlreadyInProgress =
86+ status === 409 && error . errors ?. [ 0 ] ?. code === 'checkout_already_in_progress' ;
87+
88+ return isServerError || checkoutAlreadyInProgress ;
8089 } ,
8190 } ,
8291 ) ;
You can’t perform that action at this time.
0 commit comments