-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Description
When trying to add a string of considerable size such as >7 MB, the archive.entry exits abruptly without any exception and exit code - 0.
Below is sample code
const ZipStream = require('zip-stream');
const archive = new ZipStream();
function arrayToCsv(dataArray) {
const output = dataArray.map((val) => {
if (val === null || val === undefined) {
return '';
}
const modVal = `${val}`; // Convert everything to string
return `"${modVal.replace(/"/g, '""')}"`;
}).join(separator);
return output;
}
function getCSV(rows, cols = 10) {
let csv = '';
for (let i = 0; i < rows; i++) { // files
const row = new Array(cols);
row.fill(`randomString${i + 1}`);
csv = csv + arrayToCsv(row) + '\n';
}
return csv;
}
process.on('exit', (code) => {
console.log(`Process exit with code - ${code}`)
});
console.log(`Before adding csv`);
csv = getCSV(20000);
archive.entry(csv, { name: 'csv1.csv', zlib: { level: 9 } }, (err, entry) => {
if (err) {
throw err
}
console.log(`After adding csv`);
archive.finish();
})
Output
Before adding csv
Process exit with code 0
The After adding csv is not printed to console.
I have used object-sizeof to calculate size of csv
size of csv - 7777880 OR 7.42 MB
For lower sizes, it works fine.
Please let me know if there is anything wrong with the code above.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels