Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TableOfContentsc causes timeout when {{ exists in code block. #10654

Closed
willhaines opened this issue Jan 26, 2023 · 6 comments · Fixed by #10655
Closed

TableOfContentsc causes timeout when {{ exists in code block. #10654

willhaines opened this issue Jan 26, 2023 · 6 comments · Fixed by #10655

Comments

@willhaines
Copy link

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.110.0-e32a493b7826d02763c3b79623952e625402b168+extended linux/amd64 BuildDate=2023-01-17T12:16:09Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes.

Description

I discovered this while using the geekdocs theme, but as far as I can tell the bug is not specific to that theme.

If your page has:
1. A code block with the sequence {{ somewhere in it
2. That code block is wrapped in a shortcode that renders it to html
3. A table of contents
then, it will cause a timeout and fail to render.

Oddly enough, removing the table of contents from such a page fixes the problem. As does, having the code block not be wrapped in a shortcode.

Error message

$ hugo server
Start building sites …
hugo v0.110.0-e32a493b7826d02763c3b79623952e625402b168+extended linux/amd64 BuildDate=2023-01-17T12:16:09Z VendorInfo=gohugoio
Error: Error building site: "/tmp/my_hugo/content/posts/my-first-post.md:1:1": timed out initializing value. You may have a circular loop in a shortcode, or your site may have resources that take longer to build than the `timeout` limit in your Hugo config file.
Built in 30068 ms

How to reproduce

layouts/shortcodes/noop.html

{{ .Inner | $.Page.RenderString }}

layouts/shortcodes/toc.html

{{ .Page.TableOfContents }}

content/posts/my-first-post.md

---
title: "My First Post"
date: 2023-01-24T13:08:10-07:00
draft: false
---

{{< toc >}}

## this is a heading

{{< noop >}}
```
this is some code
   containing
     {{ sequence
```
{{< /noop >}}
@jmooring
Copy link
Member

When you include .TableOfContents in a shortcode, it forces the current page to be rendered, which includes the shortcode...

🐔 → 🥚 → 🐔 → 🥚 → …

See https://discourse.gohugo.io/t/36758/2

@jmooring
Copy link
Member

Re-opening.

@jmooring jmooring reopened this Jan 26, 2023
@bep
Copy link
Member

bep commented Jan 26, 2023

To be clear:

This should work:

In a shortcode in page "foo":

{{ .Page.TableOfContents }}

Should work.

{{ (site.GetPage "foo" ).TableOfContents }}

Will create an infinite recursion.

What I suspect is creating a infinite recursion above is the noop shortcode with:

{{ .Inner | $.Page.RenderString }}

I'm pretty sure it's not about any {{ in the code block, and I suspect you need to simplify your shortcode setup to make this work.

@jmooring
Copy link
Member

I can reproduce this as described with v0.100.0 and later, but not with v0.99.1.

Git bisect says 9e904d7 is the first bad commit.

git clone --single-branch -b hugo-github-issue-10654 https://github.com/jmooring/hugo-testing hugo-github-issue-10654
cd hugo-github-issue-10654
hugo server

@bep
Copy link
Member

bep commented Jan 26, 2023

Ah, OK, yea then I understand, thanks for the clarification...

@bep bep removed the NeedsTriage label Jan 26, 2023
@bep bep modified the milestones: v0.110.0, v0.111.0 Jan 26, 2023
bep added a commit to bep/hugo that referenced this issue Jan 26, 2023
bep added a commit that referenced this issue Jan 26, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants