๐ [Bug]: request fail before the template is available
iacore opened this issue ยท 5 comments
Bug Description
Observable behavior (recalled from my memory):
/layout template not found
How to Reproduce
I don't know! I only saw it once.
the actual application in question is https://codeberg.org/vnpower/pixivfe
where i
go run .
- visit
http//localhost:8282/
in browser
I couldn't get it to reproduce again.
I suspect this is a race condition
Expected Behavior
The server should not respond to requests if the templates are not compiled yet.
Fiber Version
v2.52.0
Code Snippet (optional)
No response
Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my problem prior to opening this one.
- I understand that improperly formatted bug reports may be closed without explanation.
Thanks for opening your first issue here! ๐ Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord
I think I found the problem. there is no mutex
search for the following code snippet in github.com/gofiber/template
if !e.Loaded || e.ShouldReload {
if e.ShouldReload {
e.Loaded = false
}
if err := e.Load(); err != nil {
return err
}
}
if e.ShouldReload
is true, then after e.Load()
e.Loaded
still could be false (if the surrounding function is called twice in quick succession.
Thanks!
I also noticed that the Jet template engine doesn't output any error when the template is broken. It just... renders until the broken part, result in partially rendered page. Are you aware of this issue too?