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

refactor: extract structs for downloading tarballs and npm registry packuments #24067

Merged
merged 6 commits into from
Jun 3, 2024

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Jun 1, 2024

This is part of the work for #24063 where we need to ensure npm installation works properly on many workers.

This extracts out two structs that can be shared amongst the workers. One for downloading and extracting npm tarballs and another for downloading npm registry packuments.

pub async fn load_package_info(
&self,
name: &str,
current_runtime_http_client: &Arc<HttpClient>,
Copy link
Member Author

Choose a reason for hiding this comment

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

Part of this refactor is working towards ensuring we're not sharing HttpClients amongst different runtimes. I'll make this an Rc<HttpClient> in the future.

fs: Arc<dyn FileSystem>,
fs_resolver: Arc<dyn NpmPackageFsResolver>,
global_npm_cache: Arc<NpmCache>,
resolution: Arc<NpmResolution>,
http_client: Arc<HttpClient>,
Copy link
Member Author

Choose a reason for hiding this comment

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

I'll work on ensuring this is in an ideal place later on. Just didnt' want to land a massive refactor in one go.

@@ -1,3 +1,2 @@
Download https://localhost:4260/mkdirp
Download https://localhost:4260/mkdirp
Copy link
Member Author

Choose a reason for hiding this comment

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

It downloading this multiple times was a cosmetic bug previously from #18622. We already got the latest information from the npm registry, so we don't need to download it again (this is now enforced by the RegistryInfoDownloader)

@dsherret dsherret requested a review from bartlomieju June 1, 2024 01:43

use super::NpmCache;

// todo(dsherret): create seams and unit test this
Copy link
Member

Choose a reason for hiding this comment

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

What does "seams" mean in this context?

Copy link
Member Author

Choose a reason for hiding this comment

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

A seam is a place in the code where you can modify the behaviour for testing without modifying the code. I believe it's a term coinded by Michael Feathers from the book "working effectively with legacy code" (probably one of the best books I've read). I kind of view it as a general term for a bunch of different techniques used for making code more testable.

@dsherret dsherret enabled auto-merge (squash) June 3, 2024 01:26
@dsherret dsherret merged commit b1f776a into denoland:main Jun 3, 2024
17 checks passed
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.

None yet

2 participants