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

Hugo server crash when saving a partial used in content adapter #12538

Closed
irkode opened this issue May 24, 2024 · 8 comments · Fixed by #12553
Closed

Hugo server crash when saving a partial used in content adapter #12538

irkode opened this issue May 24, 2024 · 8 comments · Fixed by #12553

Comments

@irkode
Copy link

irkode commented May 24, 2024

Steps to reproduce (Hugo 126.1 on Windows 11)

  • hugo new && hugo new theme

  • create layouts/partials/gettitle.html

    {{ return "This will crash when saved" }} 
  • create content/_content.gotmpl

    {{ $title := partial "gettitle.html" }}
    {{ $content := dict "mediaType" "text/markdown" "value" "## Hello" }}
    {{ $page := dict "content" $content "title" $title "path" $title }}
    {{ $.AddPage $page }}
  • fire up hugo server

  • visit site to see the text headline at the bottom of the page

  • edit layouts/partials/gettitle.html

    {{ return "This will crash when saved - BOOM!" }} 

    in fact the change does not matter a simple blank or newline will do

>>> hugo server
Watching for changes in C:\_repos\github\hugo-github-issue\{archetypes,assets,content,data,i18n,layouts,static,themes}
Watching for config changes in C:\_repos\github\hugo-github-issue\hugo.toml, C:\_repos\github\hugo-github-issue\themes\hugo\hugo.toml
Start building sites …
hugo v0.126.1-3d40aba512931031921463dafc172c0d124437b8+extended windows/amd64 BuildDate=2024-05-15T10:42:34Z VendorInfo=gohugoio


                   | EN
-------------------+-----
  Pages            | 19
  Paginator pages  |  0
  Non-page files   |  1
  Static files     |  1
  Processed images |  0
  Aliases          |  0
  Cleaned          |  0

Built in 14 ms
Environment: "development"
Serving pages from disk
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Change detected, rebuilding site (#1).
2024-05-24 21:51:56.713 +0200
Template changed /partials/gettitle.html
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Total in 5 ms
panic: html/template: cannot Clone "" after it has executed

goroutine 23 [running]:
github.com/gohugoio/hugo/tpl/internal/go_templates/htmltemplate.Must(...)
        /root/project/hugo/tpl/internal/go_templates/htmltemplate/template.go:369
github.com/gohugoio/hugo/tpl/tplimpl.(*templateNamespace).createPrototypes(0xc001227740)
        /root/project/hugo/tpl/tplimpl/template.go:985 +0xa9
github.com/gohugoio/hugo/tpl/tplimpl.(*templateExec).MarkReady.func1()
        /root/project/hugo/tpl/tplimpl/template.go:314 +0x3c
sync.(*Once).doSlow(0x21095f?, 0x286fb20?)
        /usr/local/go/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
        /usr/local/go/src/sync/once.go:65
github.com/gohugoio/hugo/tpl/tplimpl.(*templateExec).MarkReady(0x2432e40?)
        /root/project/hugo/tpl/tplimpl/template.go:311 +0x59
github.com/gohugoio/hugo/hugolib.newHugoSites.func3({0x0?, 0xc0000580c0?})
        /root/project/hugo/hugolib/site_new.go:356 +0xab
github.com/gohugoio/hugo/lazy.(*Init).Do.func1()
        /root/project/hugo/lazy/init.go:107 +0xe2
github.com/gohugoio/hugo/lazy.(*onceMore).Do(0xc50403?, 0xc00004b110?)
        /root/project/hugo/lazy/once.go:53 +0x129
github.com/gohugoio/hugo/lazy.(*Init).Do(0xc00074b730, {0x4253308?, 0x55bcda0?})
        /root/project/hugo/lazy/init.go:88 +0x65
github.com/gohugoio/hugo/lazy.(*Init).Do.func1()
        /root/project/hugo/lazy/init.go:112 +0x18a
github.com/gohugoio/hugo/lazy.(*onceMore).Do(0x27f3ad?, 0x6650efdc?)
        /root/project/hugo/lazy/once.go:53 +0x129
github.com/gohugoio/hugo/lazy.(*Init).Do(0xc00074a690, {0x4253308?, 0x55bcda0?})
        /root/project/hugo/lazy/init.go:88 +0x65
github.com/gohugoio/hugo/hugolib.(*HugoSites).render(0xc000a34000, {0x425c2f0?, 0xc0000b0960?}, 0xc0013096c0)
        /root/project/hugo/hugolib/hugo_sites_build.go:327 +0x132
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build(0xc000a34000, {0x0, 0x0, 0x0, 0x0, 0xc0008a0c60, 0x0, 0x1, 0x0}, {0xc00054b140, ...})
        /root/project/hugo/hugolib/hugo_sites_build.go:168 +0x77b
github.com/gohugoio/hugo/commands.(*hugoBuilder).rebuildSites(0xc00076f380, {0xc00054b140, 0x2, 0x2})
        /root/project/hugo/commands/hugobuilder.go:1019 +0x188
github.com/gohugoio/hugo/commands.(*hugoBuilder).handleEvents.func6(0xc00076f380, 0xc001790600)
        /root/project/hugo/commands/hugobuilder.go:864 +0x8b
github.com/gohugoio/hugo/commands.(*hugoBuilder).handleEvents(0xc00076f380, 0xc0001116b0, 0xc0007d01a8, {0xc001066f00, 0x2, 0x2}, 0xc000120570)
        /root/project/hugo/commands/hugobuilder.go:867 +0x13ba
github.com/gohugoio/hugo/commands.(*hugoBuilder).newWatcher.func2()
        /root/project/hugo/commands/hugobuilder.go:352 +0x25d
created by github.com/gohugoio/hugo/commands.(*hugoBuilder).newWatcher in goroutine 1
        /root/project/hugo/commands/hugobuilder.go:343 +0x4c5

What version of Hugo are you using?

hugo v0.126.1-3d40aba512931031921463dafc172c0d124437b8+extended windows/amd64 BuildDate=2024-05-15T10:42:34Z VendorInfo=gohugoio
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.22.2"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.3.2"
@irkode
Copy link
Author

irkode commented May 24, 2024

Did not crash on Windows 11 WSL2

  • Ubuntu 22.04.4 LTS
  • and openSUSE Tumbleweed VERSION_ID="20240407"

@irkode irkode changed the title Hugo server crash when saving a partial used in a content Adapter Hugo server crash when saving a partial used in content Adapter (Windows 11) May 25, 2024
@jmooring
Copy link
Member

Reproducible on Linux.

@jmooring jmooring changed the title Hugo server crash when saving a partial used in content Adapter (Windows 11) Hugo server crash when saving a partial used in content adapter May 25, 2024
@irkode
Copy link
Author

irkode commented May 26, 2024

regarding WSL won't crash:

I tested this with being in the windows path mounted

cd /mnt/c/_repos/github/hugo-github-issue
hugo server
  • The browser used does not run in WSL

  • editing the code was done in WSL

  • With this setup the server does not crash, but also no change is displayed

  • viewing the shortcode in WSL and Windows both shows the same content

=> looks like hugo server does not see the change from windows in the WSL context.

being in a WSL folder ~/hugo-forum-issue

  • copied the files to the WSL linux filesystem
  • start hugo server
  • browser running on windows
  • editing the file

=> it crashes

Conclusion WSL

  • normal WSL usage it crashes
    • same as in Windows and Linux (as tested by @jmooring
  • mixed access (WSL mounted filesystem)
    • no crash no update - I consider this as an unusual edge case

@bep bep self-assigned this May 29, 2024
@bep bep removed the NeedsTriage label May 29, 2024
@bep bep added this to the v0.127.0 milestone May 29, 2024
@bep
Copy link
Member

bep commented May 29, 2024

I cannot reproduce this on MacOS and we have a very similar (and passing on all platforms) integration test. I don't doubt that this is a real issue, but I'm just saying that it's hard for me to fix (yes, I have some VMs I can boot up, but that may take some ... days).

@bep bep removed their assignment May 29, 2024
@irkode
Copy link
Author

irkode commented May 29, 2024

All ok. As workaround i just add the partial directly to a layout. Once it's ready I take it over to the adapter.
If there's anything addinional you like me to test. Just drop me a note.

@bep
Copy link
Member

bep commented May 30, 2024

Never mind, I actually can reproduce it -- I just didn't follow the (excellent) issue description to the letter.

@bep bep self-assigned this May 30, 2024
@bep bep modified the milestones: v0.127.0, v0.126.2 May 30, 2024
bep added a commit to bep/hugo that referenced this issue May 30, 2024
bep added a commit that referenced this issue May 30, 2024
@irkode
Copy link
Author

irkode commented May 30, 2024

good job, thx - works like a charm on Windows and WSL

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 Jun 21, 2024
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