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; })); }