Skip to content

Commit

Permalink
Run on all Node versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfranklin committed Apr 24, 2020
1 parent 449da6c commit af5a622
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/BrowserFetcher.ts
Expand Up @@ -339,19 +339,21 @@ async function extractZip(zipPath: string, folderPath: string): Promise<void> {
* If the user is on Node < 14 we maintain the behaviour we had before
* this patch.
*/
if (nodeVersion === 'v14.0.0') {
await new Promise((resolve, reject) => {
let extractedResolved = false;
setTimeout(async() => {
await extract(zipPath, {dir: folderPath});
extractedResolved = true;
}, 10);

if (extractedResolved)
resolve();
else
reject(`Puppeteer currently does not work on Node v14 due to an upstream bug. Please see: https://github.com/puppeteer/puppeteer/issues/5719 for details.`);
});
if (nodeVersion.startsWith('v14.')) {
let timeoutReject;
const timeoutPromise = new Promise((resolve, reject) => { timeoutReject = reject; });

const timeoutToken = setTimeout(() => {
const error = new Error(`Puppeteer currently does not work on Node v14 due to an upstream bug. Please see: https://github.com/puppeteer/puppeteer/issues/5719 for details.`);
timeoutReject(error);
}, 10 * 1000);

await Promise.race([
extract(zipPath, {dir: folderPath}),
timeoutPromise
]);

clearTimeout(timeoutToken);
} else {
try {
await extract(zipPath, {dir: folderPath});
Expand Down

0 comments on commit af5a622

Please sign in to comment.