This repository was archived by the owner on Oct 10, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -470,6 +470,22 @@ test('Can timeout access token polling', async (t) => {
470470 t . false ( scope . isDone ( ) )
471471} )
472472
473+ test ( 'Retries on server errors' , async ( t ) => {
474+ const accountId = uuidv4 ( )
475+ const expectedResponse = { test : 'test' }
476+ const scope = nock ( origin )
477+ . get ( `${ pathPrefix } /accounts/${ accountId } ` )
478+ . reply ( 500 )
479+ . get ( `${ pathPrefix } /accounts/${ accountId } ` )
480+ . reply ( 200 , expectedResponse )
481+
482+ const client = getClient ( )
483+ const response = await client . getAccount ( { account_id : accountId } )
484+
485+ t . deepEqual ( response , expectedResponse )
486+ t . true ( scope . isDone ( ) )
487+ } )
488+
473489test ( 'Handles API rate limiting' , async ( t ) => {
474490 const accountId = uuidv4 ( )
475491 const retryAtMs = Date . now ( ) + TEST_RATE_LIMIT_DELAY
Original file line number Diff line number Diff line change 22// - when receiving a rate limiting response
33// - on network failures due to timeouts
44const shouldRetry = function ( { response = { } , error = { } } ) {
5- return response . status === RATE_LIMIT_STATUS || RETRY_ERROR_CODES . has ( error . code )
5+ return isRetryStatus ( response ) || RETRY_ERROR_CODES . has ( error . code )
6+ }
7+
8+ const isRetryStatus = function ( { status } ) {
9+ return typeof status === 'number' && ( status === RATE_LIMIT_STATUS || String ( status ) . startsWith ( '5' ) )
610}
711
812const waitForRetry = async function ( response ) {
You can’t perform that action at this time.
0 commit comments