From c8a26808dd3fb2730d5428873f597ddcb5f9952c Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 31 Mar 2025 09:38:09 -0700 Subject: [PATCH 1/2] chore: remove ci test "selflink" opt-out for darwin+arm64 --- workspaces/arborist/test/fixtures/index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/workspaces/arborist/test/fixtures/index.js b/workspaces/arborist/test/fixtures/index.js index 1ec9159a2b598..fdc1ea1e3770f 100644 --- a/workspaces/arborist/test/fixtures/index.js +++ b/workspaces/arborist/test/fixtures/index.js @@ -20,11 +20,7 @@ const roots = [ 'optofdev', 'other', 'root', - // This test flakes out on Apple Silicon - // https://github.com/npm/cli/pull/7411 - process.platform === 'darwin' && process.arch === 'arm64' - ? null - : 'selflink', + 'selflink', 'symlinked-node-modules/example', 'workspace', 'workspace2', From 3069e7cac00484ef0771a173212f08d876bb1952 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Fri, 4 Apr 2025 08:15:02 -0700 Subject: [PATCH 2/2] fix: properly handle link and non-link nodes regardless of processing order --- .../arborist/lib/arborist/load-actual.js | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/workspaces/arborist/lib/arborist/load-actual.js b/workspaces/arborist/lib/arborist/load-actual.js index 2add9553688a4..cd0147149d543 100644 --- a/workspaces/arborist/lib/arborist/load-actual.js +++ b/workspaces/arborist/lib/arborist/load-actual.js @@ -331,15 +331,29 @@ module.exports = cls => class ActualLoader extends cls { async #loadFSTree (node) { const did = this.#actualTreeLoaded - if (!node.isLink && !did.has(node.target.realpath)) { - did.add(node.target.realpath) - await this.#loadFSChildren(node.target) + + // For links, process the target node + // For regular nodes, process the node itself + const nodeToProcess = node.isLink ? node.target : node + + // Skip if already processed or if nodeToProcess is undefined + if (!nodeToProcess || did.has(nodeToProcess.realpath)) { + return Promise.resolve() + } + + did.add(nodeToProcess.realpath) + await this.#loadFSChildren(nodeToProcess) + + // Process children if they exist + if (nodeToProcess.children.size > 0) { return Promise.all( - [...node.target.children.entries()] - .filter(([, kid]) => !did.has(kid.realpath)) + [...nodeToProcess.children.entries()] + .filter(([, kid]) => kid && !did.has(kid.realpath)) .map(([, kid]) => this.#loadFSTree(kid)) ) } + + return Promise.resolve() } // create child nodes for all the entries in node_modules