Repository: gohugoio/hugo (language: go)

Issue:
Possible infinite loop in Hugo Modules download
See https://github.com/gohugoio/hugoThemesSiteBuilder/issues/447

That project is rather special, as it builds 500 themes configured as Hugo Modules, but we currently have a state where the `hugo --config config.json config mounts` just hangs in what seems to be an infinite loop.

We have a check in there that we don't visit the same module twice, but there may some path/redirection issue that I have not thought about.

/cc @zetxek


Discussion / hints:

Fix patch:
diff --git a/modules/collect.go b/modules/collect.go
index e7d5dbe292c..dff71924be3 100644
--- a/modules/collect.go
+++ b/modules/collect.go
@@ -261,7 +261,10 @@ func (c *collector) add(owner *moduleAdapter, moduleImport Import) (*moduleAdapt
 					// This will select the latest release-version (not beta etc.).
 					versionQuery = "upgrade"
 				}
-				if err := c.Get(fmt.Sprintf("%s@%s", modulePath, versionQuery)); err != nil {
+
+				// Note that we cannot use c.Get for this, as that may
+				// trigger a new module collection and potentially create a infinite loop.
+				if err := c.get(fmt.Sprintf("%s@%s", modulePath, versionQuery)); err != nil {
 					return nil, err
 				}
 				if err := c.loadModules(); err != nil {


Test patch: