node-archiver
node-archiver copied to clipboard
Heap out of memory with archiver.append()
Got a Heap out of memory error, I am appending 1,000,000 file streams to the archive.append(file_stream, { name: file_name }) one by one in a loop seems like the archiver keeps the reference of all streams in heap memory finally throwing the Heap out of memory error.
// After archiver initialization and pipe to the output stream ... ... for (const file of files) { const result = await S3Service.createLazyDownloadStream(file); if (result.fileResponse) { try { archive.append(result.stream, {name: getKeyPath(result)}); } catch (error) { Logger.logInfo('Error appending to archive:'+ error); } } } await archive.finalize(); ... ...
Have you found the reason?