gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
73.52k stars 7.38k forks source link

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

Closed irkode closed 1 month ago

irkode commented 1 month ago

Steps to reproduce (Hugo 126.1 on Windows 11)

>>> 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 commented 1 month ago

Did not crash on Windows 11 WSL2

jmooring commented 1 month ago

Reproducible on Linux.

irkode commented 1 month ago

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

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

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

=> it crashes

Conclusion WSL

bep commented 1 month ago

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).

irkode commented 1 month ago

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 commented 1 month ago

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

irkode commented 1 month ago

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

github-actions[bot] commented 1 week ago

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.