Skip to content

Commit

Permalink
Avoid uncaught error from pooledMap
Browse files Browse the repository at this point in the history
Filed upstream: denoland/std#2197
  • Loading branch information
danopia committed May 7, 2022
1 parent e3c57ff commit 1011cb0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/helpers/s3-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ export async function multiPartUpload(
// Actually process the stream and do the transfers
const segments = params.Body.pipeThrough(newPartSegmenter(partSize));
const partEtags = new Array<CompletedPart>();
let putObjectResp: PutObjectOutput | null = null;
for await (const part of pooledMap(queueSize, segments, uploadSegment)) {
if (part.putObject) {
// If putObject was used, we return the response immediately
return part.putObject;
// It would be cleaner to return here, but pooledMap doesn't like being canceled:
// https://github.com/denoland/deno_std/issues/2197
putObjectResp = part.putObject;
} else {
partEtags.push(part.uploadPart);
}
partEtags.push(part.uploadPart);
}
if (putObjectResp) return putObjectResp;
if (!uploadId) throw new Error(`BUG: No S3 multipart operatinon was started.`);

// Finish up
Expand Down

0 comments on commit 1011cb0

Please sign in to comment.