nunocoracao / blowfish

Personal Website & Blog Theme for Hugo
https://blowfish.page
MIT License
1.35k stars 380 forks source link

Infinite loop in the article shortcodes. #1595

Closed 16bit-ykiko closed 4 days ago

16bit-ykiko commented 2 months ago

Describe the bug When two articles contain links to each other, it will lead to infinite recursion.

To Reproduce Steps to reproduce the behavior:

  1. crate two files
  2. use the other article's link as article shortcodes
<!-- a.md -->
{{< article link="/b.md" >}}

<!-- b.md -->
{{< article link="/a.md" >}}

Expected behavior There is no reason resulting in a compile error.

Screenshots

Desktop (please complete the following information):

Hugo & Blowfish versions

capehart commented 1 month ago

This was interesting. I'm deploying a new (and still fairly small) site on AWS Amplify. I also got the "infinite recursion or slow template" message (see below). I bumped the timeout config from 30 sec to 90 sec, at which point, the error message was slightly briefer. So, I bumped the timeout again, to 180 seconds at which point the build succeeded.

Maybe it's not actually an infinite recursion but just an unusually expensive process somewhere along in there?

 # Executing command: hugo
2024-07-22T04:01:06.178Z [INFO]: Start building sites …
2024-07-22T04:01:06.188Z [INFO]: hugo v0.120.4-f11bca5fec2ebb3a02727fb2a5cfb08da96fd9df+extended linux/amd64 BuildDate=2023-11-08T11:18:07Z VendorInfo=gohugoio
2024-07-22T04:02:36.292Z [INFO]: ERROR render of "page" failed: "/codebuild/output/src2424578257/src/travel/themes/blowfish/layouts/_default/baseof.html:8:4": execute of template failed: template: _default/single.html:8:4: executing "_default/single.html" at <partial "head.html" .>: error calling partial: partial "head.html" timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the 'timeout' config setting.
2024-07-22T04:02:36.307Z [INFO]:
2024-07-22T04:02:36.308Z [INFO]: Total in 90284 ms
Error: error building site: render: failed to render pages: render of "page" failed: "/codebuild/output/src2424578257/src/travel/themes/blowfish/layouts/_default/baseof.html:8:4": execute of template failed: template: _default/single.html:8:4: executing "_default/single.html" at <partial "head.html" .>: error calling partial: partial "head.html" timed out after 30s. This is most likely due to infinite recursion. If this is just a slow template, you can try to increase the 'timeout' config setting.
2024-07-22T04:02:36.368Z [ERROR]: !!! Build failed
2024-07-22T04:02:36.368Z [ERROR]: !!! Error: Command failed with exit code 1
nunocoracao commented 4 days ago

Hey everyone, I ran into the same problem myself. There is nothing I can do at theme level, as far as I know, that can fix this. The intelligence to resolve these loops needs to exist in the engine. Feel free to open this in the Hugo repo. Closing this ticket.

Also, if someone has a solution that could be implemented theme level I would happily be proven wrong as I also would like to have this.

@16bit-ykiko work around suggestion -> this was the reason why I implemented support for series and related articles, this allowed me to achieve some of the linkage I wanted without relying on specific article links