Skip to content

Commit 2a68516

Browse files
committed
chore: improved async iterable error handling with minimal performance impact
1 parent 1bd3255 commit 2a68516

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/lib-storage/src/s3-transfer-manager/S3TransferManager.e2e.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,18 @@ describe(S3TransferManager.name, () => {
238238
}).done();
239239
const tm: S3TransferManager = mode === "PART" ? tmPart : tmRange;
240240
const controller = new AbortController();
241-
setTimeout(() => controller.abort(), 100);
242241
try {
243242
await tm.download(
244243
{ Bucket, Key },
245244
{
246245
abortSignal: controller.signal,
246+
eventListeners: {
247+
transferInitiated: [
248+
() => {
249+
controller.abort();
250+
},
251+
],
252+
},
247253
}
248254
);
249255
expect.fail("Download should have been aborted");

lib/lib-storage/src/s3-transfer-manager/join-streams.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ export async function joinStreams(
2525
});
2626
return sdkStreamMixin(newReadableStream);
2727
} else {
28-
// TODO: The following line is a temp fix to handle error thrown in async iterable.
29-
// We should find a better solution to improve performance.
30-
await Promise.all(streams);
28+
streams.forEach((stream) => stream.catch(() => {}));
29+
3130
return sdkStreamMixin(Readable.from(iterateStreams(streams, eventListeners)));
3231
}
3332
}

0 commit comments

Comments
 (0)