Something wrong with Leaf when run on the server

Hello,

I have a problem with Vapor template “Leaf”. it rendered html from the wrong leaf file.
such as Acronym.leaf is not called when I requested https://xxx.com/acronyms/1.
But it rendered html from index.leaf instead.

Then ,I tried to stop running the project and restart my project again on the server.
This time when request https://xxx.com/acronyms/1, it work properly. Acronym.leaf is rendered.
But when I requested https://xxx.com,it not rendered html from index.leaf, but Acronym.leaf instead.

Then, I tried to restart running my project on the server again.
This time , it render html from index.leaf when requested https://xxx.com.
but it doesn’t render html from acronym.leaf when requested https://xxx.com/acronyms/1.

Appreciated if you could advise.

Best Regard,
Thammaporn

@thammaporn I think this is related to https://github.com/vapor/template-kit/issues/25 and https://github.com/vapor/leaf/issues/117 which looks like a bug in the way that template hashes are calculated. This should be fixed by the time Leaf is released and it may be worth looking in there for solutions.

Thanks for advice.
I found when I run the project manually using command > vapor run . Vapor render correct html page.

It seem the problem happened only when I run through supervisor.
But I don’t know how to fix it.

Is supervisor running the release build with production environment flag set?

The quick fix until the issue is resolved is to turn of caching in a custom LeafConfig

I checked my config conf file of supervisor.
It solved after delete the production environment like below.

command=vapor run -env=production
Change to
command=vapor run

However , Should we run as production environment?
Appreciated if you could advice.

Thank you.

Yes you should, since that’s the environment you’re in and things may be relying on it. Hopefully the fix is released soon, otherwise you could create a custom LeafConfig like the Leaf provider does and register that to disable caching. That will also fix the issue until the bug is fixed

Thanks for the solution.^^