From bfa73b3f22dfd6a71f123d1f22b5c7816068a8b7 Mon Sep 17 00:00:00 2001 From: 12f23eddde <12f23eddde@gmail.com> Date: Sat, 4 Dec 2021 15:36:14 +0800 Subject: [PATCH] fix: incomplete binary closes #2148 --- npm/binary-install.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/npm/binary-install.js b/npm/binary-install.js index cb84e0aab..d29314377 100644 --- a/npm/binary-install.js +++ b/npm/binary-install.js @@ -92,7 +92,21 @@ class Binary { return axios({ url: this.url, responseType: "stream" }) .then(res => { - res.data.pipe(tar.x({ strip: 1, C: this.binaryDirectory })); + const writer = tar.x({ strip: 1, C: this.binaryDirectory }); + + return new Promise((resolve, reject) => { + res.data.pipe(writer); + let error = null; + writer.on('error', err => { + error = err; + reject(err); + }); + writer.on('close', () => { + if (!error) { + resolve(true); + } + }); + }) }) .then(() => { console.log(