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

Multiple templates.Defer in same tamplate panic: deferred execution with id not found #13236

Closed
razonyang opened this issue Jan 9, 2025 · 3 comments · Fixed by #13237
Closed
Assignees
Labels
Milestone

Comments

@razonyang
Copy link
Contributor

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

$ hugo version
hugo v0.140.2-aae02ca612a02e085c08366a9c9279f4abb39d94+extended linux/amd64 BuildDate=2024-12-30T15:01:53Z VendorInfo=snap:0.140.2

Does this issue reproduce with the latest release?

Yes

Code Snippets

{{ with (templates.Defer (dict "data" (dict "foo" "bar") )) }}
{{ end }}
{{ with (templates.Defer (dict "data" (dict "fizz" "buzz") )) }}
{{ end }}

It works after removing others Defer.

Panic Log

panic: deferred execution with id "__hdeferred/cafc7706cee4572b_12__d=" not found

goroutine 247 [running]:
github.com/gohugoio/hugo/hugolib.(*Site).executeDeferredTemplates.func1.1(0xc001413901?, {0xc0015cc630, 0x23}, 0xc000257680, 0xc001273e88, 0xc001273ea0, 0xa01, 0xa24, 0xc001273e47)
        /build/hugo/parts/hugo/build/hugolib/hugo_sites_build.go:469 +0x468
github.com/gohugoio/hugo/hugolib.(*Site).executeDeferredTemplates.func1({0xc000a36f8d, 0x27})
        /build/hugo/parts/hugo/build/hugolib/hugo_sites_build.go:502 +0x247
github.com/gohugoio/hugo/hugolib.(*Site).executeDeferredTemplates.func2({0xc001273f38?, 0xc001273f18?}, {0xc000a36f8d?, 0x0?})
        /build/hugo/parts/hugo/build/hugolib/hugo_sites_build.go:519 +0x22
github.com/gohugoio/hugo/common/rungroup.Run[...].func1()
        /build/hugo/parts/hugo/build/common/rungroup/rungroup.go:64 +0xbd
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /build/hugo/parts/hugo/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:78 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 123
        /build/hugo/parts/hugo/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x96
panic: deferred execution with id "__hdeferred/cafc7706cee4572b_2__d=" not found

goroutine 251 [running]:
github.com/gohugoio/hugo/hugolib.(*Site).executeDeferredTemplates.func1.1(0xc001832978?, {0xc00177d1d0, 0x22}, 0xc000257680, 0xc00126be88, 0xc00126bea0, 0x978, 0x99a, 0xc00126be47)
        /build/hugo/parts/hugo/build/hugolib/hugo_sites_build.go:469 +0x468
github.com/gohugoio/hugo/hugolib.(*Site).executeDeferredTemplates.func1({0xc000dc1e6d, 0xb})
        /build/hugo/parts/hugo/build/hugolib/hugo_sites_build.go:502 +0x247
github.com/gohugoio/hugo/hugolib.(*Site).executeDeferredTemplates.func2({0xc00126bf38?, 0xc00126bf18?}, {0xc000dc1e6d?, 0x0?})
        /build/hugo/parts/hugo/build/hugolib/hugo_sites_build.go:519 +0x22
github.com/gohugoio/hugo/common/rungroup.Run[...].func1()
        /build/hugo/parts/hugo/build/common/rungroup/rungroup.go:64 +0xbd
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /build/hugo/parts/hugo/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:78 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 123
        /build/hugo/parts/hugo/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x96
panic: deferred execution with id "__hdeferred/cafc7706cee4572b_4__d=" not found

goroutine 255 [running]:
github.com/gohugoio/hugo/hugolib.(*Site).executeDeferredTemplates.func1.1(0xc001a00997?, {0xc001b00000, 0x22}, 0xc000257680, 0xc001263e88, 0xc001263ea0, 0x997, 0x9b9, 0xc001263e47)
        /build/hugo/parts/hugo/build/hugolib/hugo_sites_build.go:469 +0x468
github.com/gohugoio/hugo/hugolib.(*Site).executeDeferredTemplates.func1({0xc0007b8e3d, 0x16})
        /build/hugo/parts/hugo/build/hugolib/hugo_sites_build.go:502 +0x247
github.com/gohugoio/hugo/hugolib.(*Site).executeDeferredTemplates.func2({0xc001263f38?, 0xc001263f18?}, {0xc0007b8e3d?, 0x0?})
        /build/hugo/parts/hugo/build/hugolib/hugo_sites_build.go:519 +0x22
github.com/gohugoio/hugo/common/rungroup.Run[...].func1()
        /build/hugo/parts/hugo/build/common/rungroup/rungroup.go:64 +0xbd
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /build/hugo/parts/hugo/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:78 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 123
        /build/hugo/parts/hugo/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x96
@bep bep self-assigned this Jan 9, 2025
@bep bep removed the NeedsTriage label Jan 9, 2025
@bep bep added this to the v0.141.0 milestone Jan 9, 2025
@bep bep changed the title Multiple templates.Defer panic: deferred execution with id not found Multiple templates.Defer in same tamplate panic: deferred execution with id not found Jan 9, 2025
@bep
Copy link
Member

bep commented Jan 9, 2025

Can you confirm that this is about multiple Defers in the same template?

@razonyang
Copy link
Contributor Author

Yes, both of the following templates will cause panic.

image

image

@bep
Copy link
Member

bep commented Jan 9, 2025

Yea, OK, that was a stupid bug. Thanks for the report. I will have a released fix out in a day or two.

@bep bep closed this as completed in #13237 Jan 9, 2025
@bep bep closed this as completed in 61d3d20 Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants