Repository navigation
feat(pm): utoo ping - #2599
feat(pm): utoo ping#2599
Conversation
- Fix run_script to accept cwd parameter instead of using std::env::current_dir() - Add ping command to check npm registry connectivity Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello @elrrrrrrr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new ping command, which is a great addition for diagnosing registry issues. The refactoring of the configuration logic into config_file.rs and user_config.rs is a significant improvement for code clarity and maintainability. I also appreciate the automatic detection of registry semver support, which enhances the tool's intelligence. The changes are well-implemented, and I have only a couple of minor suggestions for improvement.
014304d to
746e7c9
Compare
746e7c9 to
128e2b3
Compare
7b4ecfb to
526f5b9
Compare
killagu
left a comment
There was a problem hiding this comment.
Code Review
Overall
The refactoring is well-structured and the new ping command is a useful addition. The run.rs test improvements (removing set_current_dir) are a nice side benefit. A few issues worth addressing:
1. Race condition in semver detection (High)
set_registry → detect_supports_semver loads config, probes the network, then writes back. There's no file locking — concurrent utoo processes could race on the config file and lose entries.
// user_config.rs
let mut entries = config.get_array("supports-semver").cloned().unwrap_or_default();
entries.push(new_entry);
config.set_array("supports-semver", entries, true)Consider using file locking (e.g., fs2::FileExt) when writing the global config, or at minimum document this as a known limitation.
2. Unbounded growth of supports-semver array (Medium)
Every unique registry URL gets appended but entries are never deduplicated or pruned. If a user switches registries frequently, this array grows forever. Consider:
- Deduplicating before appending (check if the URL or
!URLalready exists and update in-place) - Capping the array size
3. ping returns Ok(()) even on failure (Medium)
// ping.rs
} else {
println!("FAIL registry did not respond ({}ms)", result.latency_ms);
}
Ok(())A failed ping still returns Ok(()), so utoo ping exits with code 0 even when the registry is unreachable. Consider returning an error on failure so scripts/CI can rely on the exit code.
4. OnceLock for SUPPORTS_SEMVER — set-once but registry can change (Medium)
SUPPORTS_SEMVER is OnceLock<bool>, so once set it cannot be updated. If set_registry is called multiple times (e.g. in tests), only the first semver result sticks:
let _ = SUPPORTS_SEMVER.set(supports); // silently fails on second callConsistent with other config values using the same pattern, but worth noting.
5. ping command creates a redundant reqwest::Client (Low)
In cmd/ping.rs, a new client is built with 10s timeout, then detect_supports_semver creates another client with 5s timeout internally. Consider reusing the client or making the timeout consistent.
6. list_arrays output uses Debug format (Nit)
for (key, values) in config.list_arrays() {
println!("{key} = {:?}", values);
}{:?} will print Rust-style ["url1", "url2"]. Consider a more user-friendly format for CLI output.
Good work overall 👍 The main actionable items are #2 (dedup) and #3 (exit code).
utoo pingcommand - similar tonpm ping, it displays registry latency and returns whether semver is supported.config_file.rsuser_config.rsconfig.toml