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: Replace extract-zip with yauzl-promise #1527

Closed
wants to merge 7 commits into from

Conversation

ABuffSeagull
Copy link

@ABuffSeagull ABuffSeagull commented Mar 25, 2020

Since extract-zip is abandonware, remove it and just work with
yauzl directly.

In order to make TypeScript happy with recursive mkdir, I updated @types/node to v10 (since the min version for playwright is v10 anyway). However, this broke some other typings throughout the code.

Fixes #1510

@msftclas
Copy link

msftclas commented Mar 25, 2020

CLA assistant check
All CLA requirements met.

@JoelEinbinder
Copy link
Contributor

extract-zip is abandonware? It looks like it was last updated 3 hours ago.

@JoelEinbinder
Copy link
Contributor

Overall this makes sense though. I like any patch that reduces our dependency count. Can we easily move to yauzl directly instead of wrapping it with yauzl-promise?

@ABuffSeagull
Copy link
Author

Oh wow, extract-zip finally updated!
Anyway, yauzl uses node callbacks, so I tried to use promisify, but TypeScript doesn't like it for some reason (I don't really know TypeScript all that much).
Says that yauzl.open takes only 1 argument (the filepath), when it needs 2 (the filepath and options).
If you got any tips for wrangling with it, I would appreciate it, but otherwise I can just rewrite it to use node callbacks.

@JoelEinbinder
Copy link
Contributor

Oh wow, extract-zip finally updated!
Anyway, yauzl uses node callbacks, so I tried to use promisify, but TypeScript doesn't like it for some reason (I don't really know TypeScript all that much).
Says that yauzl.open takes only 1 argument (the filepath), when it needs 2 (the filepath and options).
If you got any tips for wrangling with it, I would appreciate it, but otherwise I can just rewrite it to use node callbacks.

Looks like typescript gets confused because open has multiple signatures. Try this:

const open = util.promisify(yauzl.open as (path: string, options: yauzl.Options, callback?: (err?: Error, zipfile?: yauzl.ZipFile) => void) => void);

Otherwise I don't think node callbacks are a big deal. Can just wrap them in a quick promise yourself. Thanks!

@aslushnikov
Copy link
Collaborator

@ABuffSeagull I'm eagerly looking forward for this to land! Do you plan to continue working on this, or do you want me to take over?

@ABuffSeagull
Copy link
Author

Don't worry, I'll have this done today. I just have more free time during weekdays than weekends for some reason.

@ABuffSeagull
Copy link
Author

Okay, hopefully should be all good now?

Copy link
Collaborator

@aslushnikov aslushnikov left a comment

Choose a reason for hiding this comment

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

@ABuffSeagull: please accept my apology for the slow response.

I looked into this, and it looks like we need to update node types first. The PR for this is here: #1690

Once it lands, we'll proceed with this one.

As for the code itself, looks good! I left a few minor comments in-line.

@@ -28,6 +29,8 @@ import { assert } from '../helper';

const unlinkAsync = util.promisify(fs.unlink.bind(fs));
const chmodAsync = util.promisify(fs.chmod.bind(fs));
const mkdirAsync = fs.promises.mkdir;
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's not use fs.promises - I think they're still experimental in node 10.

Instead, we can use good-old util.promisify:

const mkdirAsync = util.promisify(fs.mkdir.bind(fs));

src/server/browserFetcher.ts Show resolved Hide resolved
@ABuffSeagull
Copy link
Author

No problem, it's all good

@aslushnikov
Copy link
Collaborator

@ABuffSeagull the #1690 has landed - can you please re-baseline atop of tip-of-tree?

@aslushnikov
Copy link
Collaborator

@ABuffSeagull thank you for the followup!

Unfortunately, it looks like it doesn't unzip webkit on linux properly, probably due to symlinks. Looking at the extract-zip source code, it seems to me that most of this functionality is actually required here.

I'm sorry I pulled you into this - I got overly excited to drop some unnecessary complexity, but it looks like it is inevitable. At this point, I'd rather just bump extract-zip dependency.

Thank you for your contribution though! And again, sorry to spend your time without much success here.

@aslushnikov aslushnikov closed this Apr 7, 2020
@ABuffSeagull
Copy link
Author

Ah, if only I had a Mac, I could've realized earlier. And no problem! It was pretty fun figuring this out and you were very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] extract-zip fails npm audit
4 participants