Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: log useful error for Node v14 breakage #5732

Merged
merged 3 commits into from Apr 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 37 additions & 4 deletions src/BrowserFetcher.ts
Expand Up @@ -321,10 +321,43 @@ function install(archivePath: string, folderPath: string): Promise<unknown> {
}

async function extractZip(zipPath: string, folderPath: string): Promise<void> {
try {
await extract(zipPath, {dir: folderPath});
} catch (error) {
return error;
const nodeVersion = process.version;

/* There is currently a bug with extract-zip and Node v14.0.0 that
* causes extractZip to silently fail:
* https://github.com/puppeteer/puppeteer/issues/5719
*
* Rather than silenty fail if the user is on Node 14 we instead
* detect that and throw an error directing the user to that bug. The
* rejection message below is surfaced to the user in the command
* line.
*
* The issue seems to be in streams never resolving so we wrap the
* call in a timeout and give it 100ms to resolve before deciding on
jackfranklin marked this conversation as resolved.
Show resolved Hide resolved
* an error.
*
* If the user is on Node < 14 we maintain the behaviour we had before
* this patch.
*/
if (nodeVersion === 'v14.0.0') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodeVersion.startsWith('v14.')?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or do you think this is something Node.js will ship a patch for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hopeful that Node will ship a patch for it (given nodejs/node#32968).

But it could be safer to default to starts with v14. for now and then we can just ship a new release when the problem is solved, so let's do that 👍

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.`);
});
jackfranklin marked this conversation as resolved.
Show resolved Hide resolved
} else {
try {
await extract(zipPath, {dir: folderPath});
} catch (error) {
return error;
jackfranklin marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

Expand Down