Skip to content

Commit

Permalink
fix: avoid caching manifests as promises
Browse files Browse the repository at this point in the history
Somewhat related to #7276 and #7463. I don't think there is a reason to cache the promise here. And if we ever did choose to replace this with an LRUCache we would need to know the size of what we are caching which will be easier if we only cache the resulting manifest.

I also added a comment about why I think we are removing the license from manifests here. License was removed in #7126 which looks to be a purposeful change but I could not find a reason. Adding the license back in causes many snapshots to fail because the license is now present in lockfiles, so that's how I came up with the comment.
  • Loading branch information
lukekarrys committed May 3, 2024
1 parent 9c4d3c4 commit 8913a18
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions workspaces/arborist/lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1211,21 +1211,17 @@ This is a one-time fix-up, please be patient...

if (this.#manifests.has(spec.raw)) {
return this.#manifests.get(spec.raw)
} else {
const cleanRawSpec = redact(spec.rawSpec)
log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, cleanRawSpec))
const o = {
...options,
fullMetadata: true,
}
const p = pacote.manifest(spec, o)
.then(({ license, ...mani }) => {
this.#manifests.set(spec.raw, mani)
return mani
})
this.#manifests.set(spec.raw, p)
return p
}
const cleanRawSpec = redact(spec.rawSpec)
log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, cleanRawSpec))
const o = {
...options,
fullMetadata: true,
}
// The license is removed from manifests so its not stored in the lockfile (citation needed)
const mani = await pacote.manifest(spec, o).then(({ license, ...rest }) => rest)
this.#manifests.set(spec.raw, mani)
return mani
}

#nodeFromSpec (name, spec, parent, edge) {
Expand Down

0 comments on commit 8913a18

Please sign in to comment.