fix: Error handling on streams missing error handler on read streams.

Related https://github.com/outline/outline/discussions/5855
This commit is contained in:
Tom Moor
2023-09-23 18:08:36 -04:00
parent 65d3c8309e
commit 6aec085942
2 changed files with 22 additions and 12 deletions

View File

@@ -115,6 +115,14 @@ export default class ZipHelper {
currentFile: null,
};
const dest = fs
.createWriteStream(path)
.on("finish", () => {
Logger.debug("utils", "Writing zip complete", { path });
return resolve(path);
})
.on("error", reject);
zip
.generateNodeStream(
{
@@ -141,12 +149,11 @@ export default class ZipHelper {
}
}
)
.pipe(fs.createWriteStream(path))
.on("finish", () => {
Logger.debug("utils", "Writing zip complete", { path });
return resolve(path);
.on("error", (err) => {
dest.end();
reject(err);
})
.on("error", reject);
.pipe(dest);
}
);
});