File tree Expand file tree Collapse file tree 1 file changed +19
-9
lines changed
tests/functional/aws-node-sdk/test/object Expand file tree Collapse file tree 1 file changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -43,17 +43,27 @@ describe('DELETE object', () => {
4343
4444 process . stdout . write ( 'uploading parts\n' ) ;
4545 uploadId = createRes . UploadId ;
46+ // Concurrent uploads help trigger flakiness with "TimeoutError:
47+ // socket hang up" due to a keep-alive race: the server closes
48+ // an idle connection just as the client picks it from the pool.
49+ const uploadWithRetry = ( params , attempt = 0 ) =>
50+ s3 . send ( new UploadPartCommand ( params ) ) . catch ( err => {
51+ if ( attempt < 3 ) {
52+ process . stdout . write ( `Retrying UploadPart ${ params . PartNumber } `
53+ + `(attempt ${ attempt + 1 } /3): ${ err } \n` ) ;
54+ return uploadWithRetry ( params , attempt + 1 ) ;
55+ }
56+ throw err ;
57+ } ) ;
4658 const uploads = [ ] ;
4759 for ( let i = 1 ; i <= 3 ; i ++ ) {
48- uploads . push (
49- s3 . send ( new UploadPartCommand ( {
50- Bucket : bucketName ,
51- Key : objectName ,
52- PartNumber : i ,
53- Body : testfile ,
54- UploadId : uploadId ,
55- } ) )
56- ) ;
60+ uploads . push ( uploadWithRetry ( {
61+ Bucket : bucketName ,
62+ Key : objectName ,
63+ PartNumber : i ,
64+ Body : testfile ,
65+ UploadId : uploadId ,
66+ } ) ) ;
5767 }
5868 const uploadResults = await Promise . all ( uploads ) ;
5969
You can’t perform that action at this time.
0 commit comments