From 49d044ffcc786cb29a24d0d29e673c1bd6d6ed1b Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 3 May 2024 16:56:52 -0700 Subject: [PATCH] fix: avoid caching manifests as promises 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. --- .../arborist/lib/arborist/build-ideal-tree.js | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/workspaces/arborist/lib/arborist/build-ideal-tree.js b/workspaces/arborist/lib/arborist/build-ideal-tree.js index 920403d231d6d..bd7e1b253fb3b 100644 --- a/workspaces/arborist/lib/arborist/build-ideal-tree.js +++ b/workspaces/arborist/lib/arborist/build-ideal-tree.js @@ -1211,21 +1211,16 @@ 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, + } + const mani = await pacote.manifest(spec, o) + this.#manifests.set(spec.raw, mani) + return mani } #nodeFromSpec (name, spec, parent, edge) {