From 0db3f2ed50d9f3e50362c3c75516631a849cd3a8 Mon Sep 17 00:00:00 2001 From: Simon Heather Date: Wed, 30 Sep 2026 10:09:16 +0100 Subject: [PATCH] Fix race in proxy-bcrypt test that crashes Windows CI --- test/proxy-bcrypt.test.js | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/test/proxy-bcrypt.test.js b/test/proxy-bcrypt.test.js index 72c43c4a..24d75f8a 100644 --- a/test/proxy-bcrypt.test.js +++ b/test/proxy-bcrypt.test.js @@ -48,7 +48,7 @@ test('setup proxy server', (t) => { // make sure the download directory deleted then create an empty one rimraf(downloadDir).then(() => { - fs.mkdir('download', (e) => { + fs.mkdir(downloadDir, (e) => { if (e && e.code !== 'EEXIST') { t.error(e); return; @@ -88,18 +88,14 @@ test('verify node fetch with a proxy successfully downloads bcrypt pre-built', ( getBcrypt() .then((stream) => { const unzip = createUnzip(); - stream - .pipe(unzip); + const extract = tar.extract(downloadDir, tarOptions); + stream.pipe(unzip).pipe(extract); - unzip - .pipe(tar.extract(`${downloadDir}`, tarOptions)); - - return unzip; - }) - .then((stream) => { + // wait for tar-fs to finish (it sets file times after writing), not just for gunzip to end return new Promise((resolve, reject) => { - stream.on('end', resolve); - stream.on('error', reject); + unzip.on('error', reject); + extract.on('error', reject); + extract.on('finish', resolve); }); }) // if no errors on download and the file is there that's good enough. napi version @@ -117,15 +113,10 @@ test('verify node fetch with a proxy successfully downloads bcrypt pre-built', ( }); // this is really just onFinish() but local to the tests in this file -test(`cleanup after ${__filename}`, (t) => { +test(`cleanup after ${__filename}`, async () => { proxy.stopServer(); delete process.env.NOCK_OFF; delete process.env.http_proxy; delete process.env.https_proxy; - try { - rimraf(downloadDir); - } catch (err) { - // ignore errors - } - t.end(); + await rimraf(downloadDir).catch(() => {}); });