I'm still new to NodeJS and am getting a MaxListenersExceededWarning: Possible EventEmitter memory leak detected
message when I call the following function:
function zipUpFile() {
const folderPath = "./dist";
const zip = zlib.createGzip();
const zipWriteStream = fs.createWriteStream("signature-templates.zip");
fs.readdir(folderPath, (error, files) => {
if (error) {
console.error(error);
return;
}
const htmlFiles = files.filter((file) => file.endsWith(".html"));
// loop through the HTML files and pipe each one to the zip file
htmlFiles.forEach((htmlFile) => {
fs.createReadStream(`${folderPath}/${htmlFile}`)
.pipe(zip)
.pipe(zipWriteStream);
});
});
}
I'm trying to understand how event emitters work but am still having trouble finding the cause. Any help is greatly appreciated!