Skip to content

Commit

Permalink
[DOP-4170]: Add try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
branberry committed Dec 18, 2023
1 parent 01a9d71 commit 6d6a891
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions api/handlers/cache-updater/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,26 @@ async function uploadCacheToS3(repoName: string, repoOwner: string) {
}
const cacheFileStream = fs.createReadStream(`${os.tmpdir}/${cacheFileName}`);

const upload = new Upload({
client,
params: {
Bucket: BUCKET_NAME,
Key: cacheFileName,
Body: cacheFileStream,
},
});

upload.on('httpUploadProgress', (progress) => {
console.log(progress);
});

await upload.done();
try {
const upload = new Upload({
client,
params: {
Bucket: BUCKET_NAME,
Key: cacheFileName,
Body: cacheFileStream,
},
});

upload.on('httpUploadProgress', (progress) => {
console.log(progress);
});

await upload.done();
} catch (e) {
console.error('ERROR! Upload failed', e);
} finally {
cacheFileStream.close();
}
}

export async function handler({ repoName, repoOwner }: TestEvent): Promise<unknown> {
Expand Down

0 comments on commit 6d6a891

Please sign in to comment.