Skip to content

Commit 5fb686d

Browse files
committed
fix: better handling in case of internal broken pipe errors
cf #13
1 parent 6a2f698 commit 5fb686d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

scripts/download-helper.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,19 @@ function fetchDatabases(outPath) {
7979
res.on('entry', entry => {
8080
if (entry.path.endsWith('.mmdb')) {
8181
const dstFilename = path.join(outPath, path.basename(entry.path));
82-
entry.pipe(fs.createWriteStream(dstFilename));
82+
let outStream;
83+
try {
84+
outStream = fs.createWriteStream(dstFilename)
85+
} catch(e) {
86+
reject(e)
87+
}
88+
outStream.on('error', e => {
89+
reject(e)
90+
})
91+
entry.on('error', e => {
92+
reject(e);
93+
})
94+
entry.pipe(outStream);
8395
}
8496
});
8597
res.on('error', e => {

0 commit comments

Comments
 (0)