@@ -542,22 +542,25 @@ test('Gives up retrying on API rate limiting after a timeout', async (t) => {
542542 t . false ( scope . isDone ( ) )
543543} )
544544
545- test ( 'Retries on ETIMEDOUT connection errors' , async ( t ) => {
546- const accountId = uuidv4 ( )
547- const retryAtMs = Date . now ( ) + TEST_RATE_LIMIT_DELAY
548- const expectedResponse = { test : 'test' }
549- const scope = nock ( origin )
550- . get ( `${ pathPrefix } /accounts/${ accountId } ` )
551- . replyWithError ( { code : 'ETIMEDOUT' } )
552- . get ( `${ pathPrefix } /accounts/${ accountId } ` )
553- . reply ( 200 , expectedResponse )
554-
555- const client = getClient ( )
556- const response = await client . getAccount ( { account_id : accountId } )
557-
558- t . true ( Date . now ( ) >= retryAtMs )
559- t . deepEqual ( response , expectedResponse )
560- t . true ( scope . isDone ( ) )
545+ const errorCodes = [ 'ETIMEDOUT' , 'ECONNRESET' ]
546+ errorCodes . forEach ( ( code ) => {
547+ test ( `Retries on ${ code } connection errors` , async ( t ) => {
548+ const accountId = uuidv4 ( )
549+ const retryAtMs = Date . now ( ) + TEST_RATE_LIMIT_DELAY
550+ const expectedResponse = { test : 'test' }
551+ const scope = nock ( origin )
552+ . get ( `${ pathPrefix } /accounts/${ accountId } ` )
553+ . replyWithError ( { code } )
554+ . get ( `${ pathPrefix } /accounts/${ accountId } ` )
555+ . reply ( 200 , expectedResponse )
556+
557+ const client = getClient ( )
558+ const response = await client . getAccount ( { account_id : accountId } )
559+
560+ t . true ( Date . now ( ) >= retryAtMs )
561+ t . deepEqual ( response , expectedResponse )
562+ t . true ( scope . isDone ( ) )
563+ } )
561564} )
562565
563566test ( 'Recreates a function body when handling API rate limiting' , async ( t ) => {
0 commit comments