Circular shortcode content loop

Version:

Hugo Static Site Generator v0.51 linux/amd64 BuildDate: 2018-11-07T12:22:45Z

I’m in the process of moving all my post images from static/ to leaf bundles. When building my site, I sometimes get this error message:

Building sites … WARN 2018/11/29 23:05:52 Timed out creating content for page “/home/zwbetz/Development/zwbetz/content/post/maui-trip/index.md” (.Content will be empty). This is most likely a circular shortcode content loop that should be fixed. If this is just a shortcode calling a slow remote service, try to set “timeout=30000” (or higher, value is in milliseconds) in config.toml.

It usually goes away when I do a hugo --gc and/or commit all my work locally. Unfortunately it happens too infrequently for me to nail down a pattern.

Weirdly, my Netlify deploys run fine.

Here’s my shortcode. Do you guys see circular logic here? As I see it, I’m just looping through a map of image resources, then resizing them.

Shortcode
{{- $command := .Get "command" -}}
{{- $options := .Get "options" -}}
{{- $alt := .Get "alt" -}}
{{- $class := .Get "class" -}}
{{- $style := .Get "style" -}}

{{- with .Page.Resources.ByType "image" -}}
  {{- range . -}}
    {{- $original := . -}}
    {{- $new := "" -}}
    
    {{- if eq $command "Fit"}}
      {{- $new = $original.Fit $options -}}
    {{- else if eq $command "Resize"}}
      {{- $new = $original.Resize $options -}}
    {{- else if eq $command "Fill"}}
      {{- $new = $original.Fill $options -}}
    {{- else -}}
      {{- errorf "Invalid image processing command: Must be one of Fit, Fill or Resize."}}
    {{- end -}}
    
    <a href="{{ $original.Permalink }}">
      <img src="{{ $new.Permalink }}" alt="{{ $alt }}" class="{{ $class }}" style="{{ $style | safeCSS }}">
    </a>
    <br><br>
  {{- end -}}
{{- end -}}

Also, here’s my relevant content structure:

Content structure
content/
├── post
│   ├── maui-trip
│   │   ├── img
│   │   │   ├── DSC_0538.jpg
│   │   │   ├── DSC_0549.jpg
│   │   │   ├── DSC_0568.jpg
│   │   │   ├── DSC_0601.jpg
│   │   │   ├── DSC_0615.jpg
│   │   │   ├── DSC_0636.jpg
│   │   │   ├── DSC_0652.jpg
│   │   │   ├── DSC_0675.jpg
│   │   │   ├── DSC_0723.jpg
│   │   │   ├── DSC_0812.jpg
│   │   │   ├── DSC_0818.jpg
│   │   │   ├── DSC_0823.jpg
│   │   │   ├── IMG_5532.jpg
│   │   │   ├── IMG_5537.jpg
│   │   │   ├── IMG_5542.jpg
│   │   │   ├── IMG_5545.jpg
│   │   │   ├── IMG_5555.jpg
│   │   │   ├── IMG_5570.jpg
│   │   │   ├── IMG_5571-PANO.jpg
│   │   │   ├── IMG_5577.jpg
│   │   │   ├── IMG_5582.jpg
│   │   │   ├── IMG_5665.jpg
│   │   │   └── IMG_5671.jpg
│   │   └── index.md
│   ├── townes-6-ish-months-photos
│   │   ├── img
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-201.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-215.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-224.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-227.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-239.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-248.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-254.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-259.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-261.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-264.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-274.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-276.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-280.jpg
│   │   │   ├── TownesBetzMilestone-AshleyLandryPhotography-282.jpg
│   │   │   └── TownesBetzMilestone-AshleyLandryPhotography-283.jpg
│   │   └── index.md

Am temporarily marking my repo from private to public. If you wish to clone it locally:

git clone --recurse-submodules https://zwbetz@bitbucket.org/zwbetz/zwbetz.git

Note that it says “likely a circular loop”; we currently only know that “it took too long” and time out. There have been cases on low specced PCs, that the processing itself took so long. I would try to increase the timeout config value first.

I had
ignorecache = true
in the config file and same effects.

After setting
ignorecache = false
and running Hugo for 2 or 3 times all runs fast.

Do you have any cache times in your config file?

Thanks guys, makes sense. I’ll try setting the config timeout value and report back


Update: Setting timeout = 30000 in my config.toml did the trick. Thank you guys for the help :+1:

Alrighty, marking my repo as private again