Skip to content

Commit 6b4bc39

Browse files
committed
Merge branch 'bugfix/CLDSRV-835-socket-hang-up' into tmp/octopus/w/9.4/bugfix/CLDSRV-835-socket-hang-up
2 parents dceca9b + 9d7619f commit 6b4bc39

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

tests/functional/aws-node-sdk/test/object/deleteObject.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)