Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(resolve => {
try {
const archive = archiver.default('zip');
/* NodeJS's Buffer has a fixed-size heap allocation.
Here an Array, which has dynamic allocation,
is used to buffer (hold) data received from a stream
then used to construct a Buffer via Buffer.concat(Array),
a constructor of Buffer. */
const archiveBuffer = [];
const heapSnapshotBufferArr = [];
archive.on('data', chunk => archiveBuffer.push(chunk));
archive.on('finish', async () => {
/* Here uploads to S3 are incompatible with streams.
Chunked Encoding is not supported for uploads
to a pre-signed url. */
await request({