From 2f51c6f486a2432fec30e73e2d4971c2f509a111 Mon Sep 17 00:00:00 2001 From: Simon Heather Date: Wed, 30 Sep 2026 10:23:55 +0100 Subject: [PATCH] Wait for extraction to finish before reporting a download install complete --- lib/install.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/install.js b/lib/install.js index 82705428..29b49931 100644 --- a/lib/install.js +++ b/lib/install.js @@ -143,13 +143,14 @@ function place_binary(uri, targetDir, opts, callback) { log.info('install', `unpacking ${entry.path}`); }; + // resolve on extract close, not source end, so files are fully written before the caller loads them dataStream.pipe(extract(targetDir, countExtractions)) .on('error', (e) => { reject(e); + }) + .on('close', () => { + resolve(`extracted file count: ${extractions}`); }); - dataStream.on('end', () => { - resolve(`extracted file count: ${extractions}`); - }); dataStream.on('error', (e) => { reject(e); });