From cf3111288278e8dd36a09b549bd2b254e86af041 Mon Sep 17 00:00:00 2001 From: Frank Weigel Date: Tue, 26 Jun 2018 09:04:57 +0200 Subject: [PATCH] [FIX] npm translator: Fix endless loop in case of dependency cycles (#15) Fixes https://github.com/SAP/ui5-project/issues/14 . --- lib/translators/npm.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/translators/npm.js b/lib/translators/npm.js index dd494eeda..bd2b35b1e 100644 --- a/lib/translators/npm.js +++ b/lib/translators/npm.js @@ -235,6 +235,7 @@ class NpmTranslator { processPendingDeps(tree) { const queue = [tree]; + const visited = new Set(); // Breadth-first search to prefer projects closer to root while (queue.length) { @@ -242,6 +243,10 @@ class NpmTranslator { if (!project.id) { throw new Error("Encountered project with missing id"); } + if (visited.has(project.id)) { + continue; + } + visited.add(project.id); if (this.pendingDeps[project.id]) { for (let i = this.pendingDeps[project.id].parents.length - 1; i >= 0; i--) {