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

fix: npm lockfile causing cache instability #2424

Conversation

chris-olszewski
Copy link
Contributor

Bug

In order to find the correct lockfile entry for foo: ^1.0.0 in package-lock.json without performing a full scan one must know where the dependency is coming from. This is different from other lockfiles where the descriptor is enough to find the correct entry. In order to avoid performing a full scan the lockfile implementation (#1830) resolved the return values of AllDependencies to their lockfile keys instead of package names. This caused the first value of the resolved dependencies to be just the package name and version and all of the following ones to be the lockfile entry key and version. The selection of first value was dependent on map iteration causing the instability.

Fix

The most straightforward fix is to always use the lockfile key and version when adding to the list of resolved files.

Considerations

This change now means when we have lockfile information, package manager implementation details will bleed out into populating ExternalDeps. At the moment this field is only used for calculating a hash, but if we eventually want to surface this data we'd probably want to normalize it back to a simple package name and version.

Fixes #2307

@vercel
Copy link

vercel bot commented Oct 27, 2022

@chris-olszewski is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Oct 27, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Oct 27, 2022 at 8:00PM (UTC)
5 Ignored Deployments
Name Status Preview Comments Updated
examples-basic-web ⬜️ Ignored (Inspect) Oct 27, 2022 at 8:00PM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Oct 27, 2022 at 8:00PM (UTC)
examples-kitchensink-blog ⬜️ Ignored (Inspect) Oct 27, 2022 at 8:00PM (UTC)
examples-native-web ⬜️ Ignored (Inspect) Oct 27, 2022 at 8:00PM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Oct 27, 2022 at 8:00PM (UTC)

@chris-olszewski chris-olszewski marked this pull request as ready for review October 27, 2022 19:20
@chris-olszewski chris-olszewski requested a review from a team as a code owner October 27, 2022 19:20
@nathanhammond nathanhammond added the pr: automerge Kodiak will merge these automatically after checks pass label Oct 27, 2022
Copy link
Contributor

@nathanhammond nathanhammond left a comment

Choose a reason for hiding this comment

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

This seems fine; as long as we know the path forward we don't need to take it at this point.

@chris-olszewski chris-olszewski merged commit 88f37f4 into vercel:main Oct 27, 2022
@chris-olszewski chris-olszewski deleted the olszewski/fix_npm_lockfile_hash_unstability branch October 27, 2022 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: automerge Kodiak will merge these automatically after checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent "cache hit" (regression) on v1.6.0+
2 participants