Skip to content

fix: don't lock ephemeral tarball urls#9532

Merged
zkochan merged 2 commits intopnpm:mainfrom
stainless-em:lock-immutable-urls
May 14, 2025
Merged

fix: don't lock ephemeral tarball urls#9532
zkochan merged 2 commits intopnpm:mainfrom
stainless-em:lock-immutable-urls

Conversation

@stainless-em
Copy link
Contributor

Fixes #9531 by only locking redirects when the final target is immutable

@stainless-em stainless-em requested a review from zkochan as a code owner May 13, 2025 23:10
@welcome
Copy link

welcome bot commented May 13, 2025

💖 Thanks for opening this pull request! 💖
Please be patient and we will get back to you as soon as we can.

@zkochan zkochan requested a review from Copilot May 14, 2025 13:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refines the tarball resolution logic so that only immutable tarball URLs (as determined by the cache‐control header) are locked, addressing issue #9531.

  • Update test cases to explicitly differentiate between immutable and mutable tarball URLs.
  • Adjust the resolveFromTarball function to conditionally lock redirects based on the immutability of the response.
  • Update the changeset with relevant messaging.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
resolving/tarball-resolver/test/index.ts Renamed tests and added a new test to cover npm.jsr.io registry behavior.
resolving/tarball-resolver/src/index.ts Modified the tarball resolution logic to check for immutability before locking.
.changeset/bright-oranges-like.md Updated changeset to document the new behavior regarding URL locking.
Comments suppressed due to low confidence (1)

resolving/tarball-resolver/test/index.ts:21

  • [nitpick] Consider adding a corresponding test case for a mutable tarball URL from npm.jsr.io to ensure both branches of the conditional logic are fully covered.
test('tarball from npm.jsr.io registry (immutable)', async () => {


// If there are redirects, we want to get the final URL address
const { url: resolvedUrl } = await fetchFromRegistry(wantedDependency.bareSpecifier, { method: 'HEAD' })
let resolvedUrl
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding an explicit type annotation (e.g., let resolvedUrl: string) for improved clarity and type safety.

Suggested change
let resolvedUrl
let resolvedUrl: string

Copilot uses AI. Check for mistakes.
})

test('tarball not from npm registry', async () => {
test('tarball not from npm registry (mutable)', async () => {
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

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

Verify that the expected URL for mutable tarballs is correct, as the logic now preserves the original bareSpecifier when the response isn't immutable.

Copilot uses AI. Check for mistakes.
@zkochan zkochan merged commit ce42d8f into pnpm:main May 14, 2025
@welcome
Copy link

welcome bot commented May 14, 2025

Congrats on merging your first pull request! 🎉🎉🎉

Asiermosquera

This comment was marked as off-topic.

Asiermosquera

This comment was marked as spam.

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.

pnpm saves ephemeral tarball urls to lockfile when installing from github releases

4 participants