I am trying to unzip 9 files, using node-stream-zip , the code (not complete, its from lambdatest-cypress-cli publicly available git repo) is as follows :
response.data.on('end', function () {
if (response_code == 200) {
const zip = new StreamZip({ file: file_path });
zip.on("ready", () => {
zip.extract(null, old_path, (err, count) => {
console.log("Closing file ",count)
zip.close();
fs.unlinkSync(file_path);
console.log("Printing error", err);
resolve(
err
? "Extract error for " + test_id
: `Extracted ${count} entries for ` + test_id
);
});
})
}
});
However sometimes the unzip happens perfectly while other time I get this error:
node:events:495
throw er; // Unhandled 'error' event
^
Error: Bad archive
at FsRead.readUntilFoundCallback [as callback] (/Users/abhishekg/Desktop/repos/lambdatest-cypress-cli/node_modules/node-stream-zip/node_stream_zip.js:198:39)
at FsRead.readCallback (/Users/abhishekg/Desktop/repos/lambdatest-cypress-cli/node_modules/node-stream-zip/node_stream_zip.js:996:25)
at FSReqCallback.wrapper [as oncomplete] (node:fs:677:5)
Emitted 'error' event on StreamZip instance at:
at StreamZip.emit (/Users/abhishekg/Desktop/repos/lambdatest-cypress-cli/node_modules/node-stream-zip/node_stream_zip.js:651:33)
at FsRead.readUntilFoundCallback [as callback] (/Users/abhishekg/Desktop/repos/lambdatest-cypress-cli/node_modules/node-stream-zip/node_stream_zip.js:198:25)
at FsRead.readCallback (/Users/abhishekg/Desktop/repos/lambdatest-cypress-cli/node_modules/node-stream-zip/node_stream_zip.js:996:25)
There is an unhandled error and an error from line 198 at node_stream_zip.js :
if (pos === minPos) {
return that.emit('error', new Error('Bad archive'));
}
I am trying to unzip 9 files, using node-stream-zip , the code (not complete, its from lambdatest-cypress-cli publicly available git repo) is as follows :
However sometimes the unzip happens perfectly while other time I get this error:
There is an unhandled error and an error from line 198 at node_stream_zip.js :
Please suggest how can this be resolved?