diff --git a/modules/templates/htmlrenderer.go b/modules/templates/htmlrenderer.go
index 81ea660161..c3d747d12d 100644
--- a/modules/templates/htmlrenderer.go
+++ b/modules/templates/htmlrenderer.go
@@ -76,8 +76,15 @@ func HTMLRenderer(ctx context.Context) (context.Context, *render.Render) {
compilingTemplates = false
if !setting.IsProd {
watcher.CreateWatcher(ctx, "HTML Templates", &watcher.CreateWatcherOpts{
- PathsCallback: walkTemplateFiles,
- BetweenCallback: renderer.CompileTemplates,
+ PathsCallback: walkTemplateFiles,
+ BetweenCallback: func() {
+ defer func() {
+ if err := recover(); err != nil {
+ log.Error("PANIC: %v\n%s", err, log.Stack(2))
+ }
+ }()
+ renderer.CompileTemplates()
+ },
})
}
return context.WithValue(ctx, rendererKey, renderer), renderer