Skip to content

Commit eedcd6b

Browse files
CLDSRV-835: Fix flakiness tcp socket hang up
This multiple concurrent uploads can help trigger that flakiness case ``` Object Part Copy / With v4 signature When copy source was put by MPU "before each" hook for "should copy a part from a source bucket to a different destination bucket": TimeoutError: socket hang up at Socket.socketOnEnd (node:_http_client:598:25) at Socket.emit (node:events:531:35) at endReadableNT (node:internal/streams/readable:1698:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) ```
1 parent 24831d6 commit eedcd6b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,28 @@ describe('Object Part Copy', () => {
312312
throw err;
313313
}).then(() => {
314314
const partUploads = [];
315+
// Concurrent uploads help trigger flakiness with "TimeoutError:
316+
// socket hang up" due to a keep-alive race: the server closes
317+
// an idle connection just as the client picks it from the pool.
318+
const uploadWithRetry = (params, attempt = 0) =>
319+
s3.send(new UploadPartCommand(params)).catch(err => {
320+
if (attempt < 3) {
321+
process.stdout.write(`Retrying UploadPart ${params.PartNumber} `
322+
+ `(attempt ${attempt + 1}/3): ${err}\n`);
323+
return uploadWithRetry(params, attempt + 1);
324+
}
325+
throw err;
326+
});
315327
for (let i = 1; i < 10; i++) {
316328
const partBuffHere = i % 2 ? partBuff : otherPartBuff;
317329
const partHashHere = i % 2 ? partHash : otherPartHash;
318-
partUploads.push(s3.send(new UploadPartCommand({
330+
partUploads.push(uploadWithRetry({
319331
Bucket: sourceBucketName,
320332
Key: sourceMpuKey,
321333
PartNumber: i,
322334
UploadId: sourceMpuId,
323335
Body: partBuffHere,
324-
})));
336+
}));
325337
parts.push({
326338
ETag: partHashHere,
327339
PartNumber: i,

0 commit comments

Comments
 (0)