Repository navigation
fix: handle unpublished packages with undefined packument versions - #458
Merged
fregante merged 5 commits intoOct 3, 2026
Merged
Conversation
|
@isaim0011 is attempting to deploy a commit to the Broofa Personal Team on Vercel. A member of the Team first needs to authorize it. |
Member
|
Thanks for the PR! Can you push an empty commit? I'm trying something out |
Contributor
Author
|
Done! Pushed an empty commit (\24a4042). Let me know if you need anything else! |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
All reviewed changes are covered and no unresolved blocking issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Fixes crashes when npm returns unpublished package metadata without versions, with clearer errors and expanded tests.
Changes:
- Safely handles missing package versions.
- Reports unpublished and versionless packages clearly.
- Adds version-selection unit tests.
| File | Summary |
|---|---|
lib/selectVersion.ts |
Safely selects versions when metadata is incomplete. |
lib/selectVersion.test.ts |
Tests tags, semver ranges, and missing versions. |
lib/ModuleCache.ts |
Adds clearer unpublished and version errors. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
fregante
enabled auto-merge (squash)
October 3, 2026 09:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a package is unpublished on npm (such as
asdasd), the npm registry returns HTTP 200 with metadata containingtime.unpublished, butpackument.versionsisundefined.Previously,
selectVersionattempted to callObject.keys(packument.versions)directly, causing an uncaught runtime TypeError:TypeError: undefined is not an object (evaluating 'Object.keys(packument.versions)')Changes
packument.versionsinselectVersion, returningundefinedinstead of throwing a TypeError.fetchModuleFromNPM, checkpackument.time.unpublishedto throw a clear error (${moduleName} has been unpublished).${moduleName} has no published versions).lib/selectVersion.test.tsto verify dist-tag selection, semver resolution, and unpublished/missing versions.