From 3a604ba0bf113563b0666f06744a749a3c3b769b Mon Sep 17 00:00:00 2001 From: Georgios Kalpakas Date: Tue, 16 May 2017 12:31:32 +0300 Subject: [PATCH] fix(aio): fix PWA testing on Windows (and reduce flaky-ness) Adding a delay after Lighthouse has run and before killing the Chrome process avoids `ECONNREFUSED` errors on Windows and will hopefully prevent such errors occasionally appearing on CI. Based on info in: https://github.com/paulirish/pwmetrics/issues/63#issuecomment-282721068 --- aio/scripts/test-pwa-score.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aio/scripts/test-pwa-score.js b/aio/scripts/test-pwa-score.js index 505ebc96c5..dae5cc28b5 100644 --- a/aio/scripts/test-pwa-score.js +++ b/aio/scripts/test-pwa-score.js @@ -79,6 +79,9 @@ function launchChromeAndRunLighthouse(url, flags, config) { return launcher.run(). then(() => lighthouse(url, flags, config)). + // Avoid race condition by adding a delay before killing Chrome. + // (See also https://github.com/paulirish/pwmetrics/issues/63#issuecomment-282721068.) + then(results => new Promise(resolve => setTimeout(() => resolve(results), 1000))). then(results => launcher.kill().then(() => results)). catch(err => launcher.kill().then(() => { throw err; }, () => { throw err; })); }